Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
蒋波涛
/
landsurvey
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
44ea6c1a
authored
2018-03-30 17:21:56 +0800
by
chiangbt
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
更新百度地图数据及应用案例
1 parent
4165197e
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
176 additions
and
49 deletions
.idea/caches/build_file_checksums.ser
app/src/main/AndroidManifest.xml
app/src/main/java/com/pashanhoo/landsurvey/BaiduMapActivity.java
app/src/main/java/com/pashanhoo/landsurvey/GoogleMapActivity.java
app/src/main/java/com/pashanhoo/landsurvey/MainActivity.java
app/src/main/java/com/pashanhoo/landsurvey/layers/baidu/BaiduMapsTiledServiceLayer.java
app/src/main/java/com/pashanhoo/landsurvey/layers/tianditu/TianDiTuLayerTypes.java
app/src/main/java/com/pashanhoo/landsurvey/layers/tianditu/TianDiTuTiledMapServiceLayer.java
app/src/main/java/com/pashanhoo/landsurvey/utils/AppInfo.java
app/src/main/res/layout/activity_baidu_map.xml
app/src/main/res/values/strings.xml
readme.md
.idea/caches/build_file_checksums.ser
0 → 100644
View file @
44ea6c1
No preview for this file type
app/src/main/AndroidManifest.xml
View file @
44ea6c1
...
...
@@ -16,9 +16,7 @@
android:label=
"@string/app_name"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".BootActivity"
>
</activity>
<activity
android:name=
".BootActivity"
/>
<activity
android:name=
".MainActivity"
android:label=
"@string/app_name"
...
...
@@ -32,6 +30,9 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
".BaiduMapActivity"
>
</activity>
</application>
</manifest>
\ No newline at end of file
...
...
app/src/main/java/com/pashanhoo/landsurvey/BaiduMapActivity.java
0 → 100644
View file @
44ea6c1
package
com
.
pashanhoo
.
landsurvey
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.widget.Toast
;
import
com.esri.android.map.LocationDisplayManager
;
import
com.esri.android.map.MapView
;
import
com.esri.android.map.event.OnStatusChangedListener
;
import
com.esri.android.runtime.ArcGISRuntime
;
import
com.esri.core.geometry.Point
;
import
com.pashanhoo.landsurvey.layers.baidu.BaiduMapLayerTypes
;
import
com.pashanhoo.landsurvey.layers.baidu.BaiduMapsTiledServiceLayer
;
import
com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer
;
import
com.pashanhoo.landsurvey.utils.AppInfo
;
import
com.pashanhoo.landsurvey.utils.GISHelper
;
import
com.pashanhoo.landsurvey.utils.JZLocationConverter
;
public
class
BaiduMapActivity
extends
AppCompatActivity
{
private
MapView
mapView
;
// GPS定位器对象
private
LocationDisplayManager
locationDisplayManager
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_baidu_map
);
AppInfo
.
Settings
();
ArcGISRuntime
.
setClientId
(
"1eFHW78avlnRUPHm"
);
mapView
=
(
MapView
)
findViewById
(
R
.
id
.
map
);
mapView
.
setEsriLogoVisible
(
false
);
mapView
.
enableWrapAround
(
false
);
BaiduMapsTiledServiceLayer
baiduMapsTiledServiceLayer
=
new
BaiduMapsTiledServiceLayer
(
BaiduMapLayerTypes
.
BAIDU_VECTOR
);
mapView
.
addLayer
(
baiduMapsTiledServiceLayer
);
mapView
.
setOnStatusChangedListener
(
new
OnStatusChangedListener
()
{
@Override
public
void
onStatusChanged
(
Object
o
,
STATUS
status
)
{
if
(
status
==
STATUS
.
INITIALIZED
){
Point
curPt
=
JZLocationConverter
.
wgs84ToGcj02
(
AppInfo
.
initPoint
);
Point
pt
=
GISHelper
.
lonLat2Mercator
(
curPt
);
mapView
.
zoomToResolution
(
pt
,
BaiduMapsTiledServiceLayer
.
getRes
()[
10
]);
Toast
.
makeText
(
BaiduMapActivity
.
this
,
mapView
.
getCenter
().
getX
()
+
":"
+
mapView
.
getCenter
().
getY
(),
Toast
.
LENGTH_LONG
).
show
();
}
}
});
}
}
app/src/main/java/com/pashanhoo/landsurvey/GoogleMapActivity.java
View file @
44ea6c1
...
...
@@ -2,10 +2,12 @@ package com.pashanhoo.landsurvey;
import
android.location.Location
;
import
android.location.LocationListener
;
import
android.os.Environment
;
import
android.support.design.widget.FloatingActionButton
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.Toast
;
import
com.esri.android.map.LocationDisplayManager
;
import
com.esri.android.map.MapView
;
...
...
@@ -53,7 +55,7 @@ public class GoogleMapActivity extends AppCompatActivity {
//---------------------------------------------------------------------------------------------------------------------
// 高德矢量图层(含路网,含注记)
//
GaodeMapsTiledServiceLayer gaodeMapsTiledServiceLayer = new GaodeMapsTiledServiceLayer(GaodeMapLayerTypes.AMAP_VECTOR);
GaodeMapsTiledServiceLayer
gaodeMapsTiledServiceLayer
=
new
GaodeMapsTiledServiceLayer
(
GaodeMapLayerTypes
.
AMAP_VECTOR
);
// 高德影像图层(不含路网,不含注记)
// GaodeMapsTiledServiceLayer gaodeMapsTiledServiceLayer = new GaodeMapsTiledServiceLayer(GaodeMapLayerTypes.AMAP_IMAGE);
// 高德路网图层(含路网,含注记)
...
...
@@ -70,11 +72,14 @@ public class GoogleMapActivity extends AppCompatActivity {
// GeoQMapsTiledServiceLayer geoQMapsTiledServiceLayer = new GeoQMapsTiledServiceLayer(GeoQMapLayerTypes.ChinaOnlineCommunity_Mobile);
// mapView.addLayer(geoQMapsTiledServiceLayer);
mapView
.
setMaxResolution
(
156543.03392800014
);
mapView
.
setMinResolution
(
0.29858214164761665
);
Point
pt
=
GISHelper
.
lonLat2Mercator
(
AppInfo
.
initPoint
);
mapView
.
zoomToResolution
(
pt
,
GoogleMapsTiledServiceLayer
.
getRes
()[
16
]);
Point
curPt
=
JZLocationConverter
.
wgs84ToGcj02
(
AppInfo
.
initPoint
);
Point
pt
=
GISHelper
.
lonLat2Mercator
(
curPt
);
mapView
.
zoomToResolution
(
pt
,
GoogleMapsTiledServiceLayer
.
getRes
()[
17
]);
locationDisplayManager
=
mapView
.
getLocationDisplayManager
();
locationDisplayManager
.
setShowLocation
(
true
);
...
...
@@ -113,8 +118,40 @@ public class GoogleMapActivity extends AppCompatActivity {
locationDisplayManager
.
start
();
mapView
.
zoomToResolution
(
GISHelper
.
lonLat2Mercator
(
locationDisplayManager
.
getPoint
()),
GoogleMapsTiledServiceLayer
.
getRes
()[
18
]);
Point
cupt
=
GISHelper
.
mercator2lonLat
(
mapView
.
getCenter
());
Toast
.
makeText
(
GoogleMapActivity
.
this
,
cupt
.
getX
()
+
":"
+
cupt
.
getY
(),
Toast
.
LENGTH_LONG
).
show
();
}
}
});
}
@Override
public
void
onResume
()
{
super
.
onResume
();
mapView
.
unpause
();
if
(
locationDisplayManager
!=
null
)
{
locationDisplayManager
.
resume
();
}
}
@Override
public
void
onPause
()
{
super
.
onPause
();
mapView
.
pause
();
if
(
locationDisplayManager
!=
null
)
{
locationDisplayManager
.
pause
();
}
}
@Override
public
void
onStop
()
{
super
.
onStop
();
if
(
locationDisplayManager
!=
null
)
{
locationDisplayManager
.
stop
();
}
}
}
...
...
app/src/main/java/com/pashanhoo/landsurvey/MainActivity.java
View file @
44ea6c1
...
...
@@ -240,7 +240,7 @@ public class MainActivity extends AppCompatActivity {
mapView
.
zoomToResolution
(
poipt
,
t_vec
.
getRes
()[
19
]);
graphicsLayer
.
addGraphic
(
new
Graphic
(
poipt
,
new
PictureMarkerSymbol
(
getResources
().
getDrawable
(
R
.
mipmap
.
locator
)).
setOffsetY
(
16
)));
mapinfoView
.
setText
(
"当前地图级别为:"
+
t_vec
.
getCurrentLevel
());
mapinfoView
.
setText
(
"当前地图级别为:"
+
t_vec
.
getCurrentLevel
());
}
@Override
...
...
app/src/main/java/com/pashanhoo/landsurvey/layers/baidu/BaiduMapsTiledServiceLayer.java
View file @
44ea6c1
...
...
@@ -8,6 +8,8 @@ import android.util.Log;
import
com.esri.android.map.TiledServiceLayer
;
import
com.esri.android.map.event.OnStatusChangedListener
;
import
com.esri.core.geometry.Envelope
;
import
com.esri.core.geometry.GeometryEngine
;
import
com.esri.core.geometry.GeometryUtil
;
import
com.esri.core.geometry.Point
;
import
com.esri.core.geometry.SpatialReference
;
import
com.esri.core.internal.io.handler.ResponseListener
;
...
...
@@ -26,15 +28,10 @@ import java.util.concurrent.RejectedExecutionException;
*/
public
class
BaiduMapsTiledServiceLayer
extends
TiledServiceLayer
{
private
static
final
double
xmin
=
-
22041257.773878
;
private
static
final
double
ymin
=
-
32673939.6727517
;
private
static
final
double
xmax
=
22041257.773878
;
private
static
final
double
ymax
=
20851350.0432886
;
private
static
final
double
XMin
=
110.35992000000005
;
private
static
final
double
YMin
=
31.382360000000062
;
private
static
final
double
XMax
=
116.65036000000009
;
private
static
final
double
YMax
=
36.36647000000005
;
private
static
final
double
xmin
=
-
20037508.3427892
;
private
static
final
double
ymin
=
-
20037508.3427892
;
private
static
final
double
xmax
=
20037508.3427892
;
private
static
final
double
ymax
=
20037508.3427892
;
private
static
final
double
[]
res
=
{
156543.03392800014
,
78271.516963999937
,
...
...
@@ -73,13 +70,13 @@ public class BaiduMapsTiledServiceLayer extends TiledServiceLayer {
72223.819286
,
6111.909643
,
18055.954822
,
9027.9774109999998
,
4513.9887049999998
,
2256.994353
,
4513.9887049999998
,
2256.994353
,
1128.4971760000001
};
private
static
String
URL
=
"http://maps.iwxlh.com"
;
private
ResponseListener
responseListener
;
private
static
Point
origin
=
new
Point
(-
20037508.34278
7
,
20037508.342787
);
private
static
Point
origin
=
new
Point
(-
20037508.34278
92
,
20037508.3427892
);
private
BaiduMapLayerTypes
baiduMapLayerTypes
;
...
...
@@ -136,26 +133,32 @@ public class BaiduMapsTiledServiceLayer extends TiledServiceLayer {
Log
.
i
(
"baidu"
,
level
+
"/"
+
col
+
"/"
+
row
);
String
url
=
""
;
String
s
=
"Galil"
;
int
offsetV
=
(
int
)
(
Math
.
pow
(
2
,
level
-
1
));
int
zoom
=
level
-
1
;
int
offsetX
=
(
int
)
Math
.
pow
(
2
,
level
-
1
);
int
offsetY
=
offsetX
-
1
;
int
numX
=
col
-
(
int
)
Math
.
pow
(
2
,
level
-
1
);
int
numY
=
(-
row
)
+
offsetY
;
zoom
=
level
+
1
;
int
num
=
(
col
+
row
)
%
8
+
1
;
num
=
2
;
switch
(
baiduMapLayerTypes
)
{
case
BAIDU_VECTOR:
url
=
"http://online"
+
((
col
+
row
)
%
8
+
1
)
+
".map.bdimg.com/onlinelabel/?qt=tile"
+
"&x="
+
(
col
-
offsetV
)
+
"&y="
+
(
offsetV
-
row
-
1
)
+
"&z="
+
level
+
"&styles=pl"
;
break
;
case
BAIDU_IMAGE:
url
=
"http://online"
+
((
col
+
row
)
%
8
+
1
)
+
".map.bdimg.com/onlinelabel/?qt=tile"
+
"&x="
+
(
col
-
offsetV
)
+
"&y="
+
(
offsetV
-
row
-
1
)
+
"&z="
+
level
+
"&styles=sl"
;
// url= "http://online" + num + ".map.bdimg.com/tile/?qt=tile&x="+numX+"&y="+numY+"&z="+level+"&styles=pl&scaler=1&udt=20141103";
url
=
"http://online"
+
num
+
".map.bdimg.com/tile/?qt=tile&x="
+
numX
+
"&y="
+
numY
+
"&z="
+
zoom
+
"&styles=pl"
;
break
;
case
BAIDU_ROAD:
url
=
"http://online"
+
num
+
".map.bdimg.com/tile/?qt=tile&x="
+
numX
+
"&y="
+
numY
+
"&z="
+
zoom
+
"&styles=sl"
;
break
;
case
BAIDU_IMAGE:
url
=
"http://shangetu"
+
((
col
+
row
)
%
8
+
1
)
+
".map.bdimg.com/it/u="
+
"x="
+
(
col
-
offsetV
)
+
";y="
+
(
offsetV
-
row
-
1
)
+
";z="
+
level
+
"x="
+
numX
+
";y="
+
numY
+
";z="
+
zoom
+
";v=009;type=sate&fm=46"
;
break
;
case
BAIDU_TRAFFIC:
url
=
"http://its.map.baidu.com:8002/traffic/TrafficTileService?"
+
"level="
+
level
+
"&x="
+
(
col
-
offsetV
)
+
"&y="
+
(
offsetV
-
row
-
1
)
+
"level="
+
zoom
+
"&x="
+
numX
+
"&y="
+
numY
+
"&time="
+
System
.
currentTimeMillis
();
break
;
}
...
...
app/src/main/java/com/pashanhoo/landsurvey/layers/tianditu/TianDiTuLayerTypes.java
View file @
44ea6c1
...
...
@@ -24,22 +24,10 @@ public enum TianDiTuLayerTypes implements BaseTiledMapServiceType {
* 影像注记
* */
CIA_C
,
/**
* 矢量数据,web墨卡托4326
*/
VEC_W
,
/**
* 影像数据
* */
IMG_W
,
/**
* 矢量注记
* */
CVA_W
,
/**
* 影像注记
* */
CIA_W
;
TER_C
,
CTA_C
;
public
void
setName
()
{
...
...
app/src/main/java/com/pashanhoo/landsurvey/layers/tianditu/TianDiTuTiledMapServiceLayer.java
View file @
44ea6c1
...
...
@@ -190,6 +190,12 @@ public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer {
case
IMG_C:
url
.
append
(
".tianditu.com/DataServer?T=img_c&X="
).
append
(
col
).
append
(
"&Y="
).
append
(
row
).
append
(
"&L="
).
append
(
level
);
break
;
case
TER_C:
url
.
append
(
".tianditu.com/DataServer?T=ter_c&X="
).
append
(
col
).
append
(
"&Y="
).
append
(
row
).
append
(
"&L="
).
append
(
level
);
break
;
case
CTA_C:
url
.
append
(
".tianditu.com/DataServer?T=cta_c&X="
).
append
(
col
).
append
(
"&Y="
).
append
(
row
).
append
(
"&L="
).
append
(
level
);
break
;
default
:
return
null
;
}
...
...
app/src/main/java/com/pashanhoo/landsurvey/utils/AppInfo.java
View file @
44ea6c1
...
...
@@ -19,9 +19,9 @@ public class AppInfo {
public
static
SQLiteDatabase
mapcachedb
;
public
static
Point
initPoint
=
new
Point
(
1
21.56
,
29.862149
);
public
static
Point
initPoint
=
new
Point
(
1
16.39167
,
39.90333
);
public
static
double
initRes
=
TDTTileinfo
.
getRes4490
()[
6
];
public
static
double
initRes
=
TDTTileinfo
.
getRes4490
()[
17
];
// public static double initRes = TDTTileinfo.getRes4326()[6];
...
...
app/src/main/res/layout/activity_baidu_map.xml
0 → 100644
View file @
44ea6c1
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".BaiduMapActivity"
>
<com.esri.android.map.MapView
android:id=
"@+id/map"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
></com.esri.android.map.MapView>
<android.support.v7.widget.LinearLayoutCompat
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:layout_marginTop=
"16dp"
android:layout_marginLeft=
"16dp"
android:layout_marginBottom=
"16dp"
android:layout_gravity=
"top|start"
>
<android.support.design.widget.FloatingActionButton
android:id=
"@+id/gps"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"top|start"
android:layout_marginTop=
"0dp"
android:layout_marginLeft=
"0dp"
app:srcCompat=
"@mipmap/ic_my_location_white_48dp"
/>
</android.support.v7.widget.LinearLayoutCompat>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
44ea6c1
...
...
@@ -9,4 +9,5 @@
<string
name=
"drawer_item_section_header1"
>
图层控制
</string>
<string
name=
"drawer_item_section_header2"
>
版权信息
</string>
<string
name=
"title_activity_baidu_map"
>
BaiduMapActivity
</string>
</resources>
...
...
readme.md
View file @
44ea6c1
...
...
@@ -13,8 +13,10 @@
-
TianDiTuLayerTypes
-
VEC_C,矢量图层
-
IMG_C,影像图层
-
TER_C,地形层
-
CVA_C,矢量注记层
-
CIA_C,影像注记层
-
CTA_C,地形注记层
腾讯图层
...
...
@@ -62,7 +64,7 @@ Point initPoint = new Point(121.56, 29.862149);
mapView.zoomToResolution(initPoint, t_vec.getRes()[16]);
```
其它
其它
(以Tencent图层为例)
```
TencentMapsTiledServiceLayer tencentMapsTiledServiceLayer = new TencentMapsTiledServiceLayer(TencentMapLayerTypes.TENCENT_MAP_VECTOR);
mapView.addLayer(tencentMapsTiledServiceLayer);
...
...
Please
register
or
sign in
to post a comment