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
4a92846d
authored
2018-03-30 11:26:04 +0800
by
chiangbt
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
腾讯地图图层
1 parent
fde2caee
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
282 additions
and
18 deletions
app/src/main/java/com/pashanhoo/landsurvey/GoogleMapActivity.java
app/src/main/java/com/pashanhoo/landsurvey/layers/baidu/BaiduMapsTiledServiceLayer.java
app/src/main/java/com/pashanhoo/landsurvey/layers/gaode/GaodeMapsTiledServiceLayer.java
app/src/main/java/com/pashanhoo/landsurvey/layers/google/GoogleMapsTiledServiceLayer.java
app/src/main/java/com/pashanhoo/landsurvey/layers/tencent/TencentMapLayerTypes.java
app/src/main/java/com/pashanhoo/landsurvey/layers/tencent/TencentMapsTiledServiceLayer.java
app/src/main/java/com/pashanhoo/landsurvey/GoogleMapActivity.java
View file @
4a92846
...
...
@@ -19,6 +19,8 @@ import com.pashanhoo.landsurvey.layers.geoq.GeoQMapLayerTypes;
import
com.pashanhoo.landsurvey.layers.geoq.GeoQMapsTiledServiceLayer
;
import
com.pashanhoo.landsurvey.layers.google.GoogleMapLayerTypes
;
import
com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer
;
import
com.pashanhoo.landsurvey.layers.tencent.TencentMapLayerTypes
;
import
com.pashanhoo.landsurvey.layers.tencent.TencentMapsTiledServiceLayer
;
import
com.pashanhoo.landsurvey.utils.AppInfo
;
import
com.pashanhoo.landsurvey.utils.GISHelper
;
import
com.pashanhoo.landsurvey.utils.JZLocationConverter
;
...
...
@@ -47,11 +49,11 @@ public class GoogleMapActivity extends AppCompatActivity {
// GoogleMapsTiledServiceLayer GOOGLE_ANNO_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_ANNO_GOOGLE_MAP);
// mapView.addLayer(GOOGLE_ANNO_Layer);
// GoogleMapsTiledServiceLayer OSM_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.OSM_Map);
// mapView.addLayer(
OSM
_Layer);
// mapView.addLayer(
GOOGLE_VECTOR
_Layer);
//---------------------------------------------------------------------------------------------------------------------
// 高德矢量图层(含路网,含注记)
GaodeMapsTiledServiceLayer
gaodeMapsTiledServiceLayer
=
new
GaodeMapsTiledServiceLayer
(
GaodeMapLayerTypes
.
AMAP_VECTOR
);
//
GaodeMapsTiledServiceLayer gaodeMapsTiledServiceLayer = new GaodeMapsTiledServiceLayer(GaodeMapLayerTypes.AMAP_VECTOR);
// 高德影像图层(不含路网,不含注记)
// GaodeMapsTiledServiceLayer gaodeMapsTiledServiceLayer = new GaodeMapsTiledServiceLayer(GaodeMapLayerTypes.AMAP_IMAGE);
// 高德路网图层(含路网,含注记)
...
...
@@ -61,8 +63,8 @@ public class GoogleMapActivity extends AppCompatActivity {
// mapView.addLayer(gaodeMapsTiledServiceLayer);
//---------------------------------------------------------------------------------------------------------------------
BaiduMapsTiledServiceLayer
baiduMapsTiledServiceLayer
=
new
BaiduMapsTiledServiceLayer
(
BaiduMapLayerTypes
.
BAIDU_TRAFFIC
);
mapView
.
addLayer
(
baidu
MapsTiledServiceLayer
);
TencentMapsTiledServiceLayer
tencentMapsTiledServiceLayer
=
new
TencentMapsTiledServiceLayer
(
TencentMapLayerTypes
.
TENCENT_MAP_VECTOR
);
mapView
.
addLayer
(
tencent
MapsTiledServiceLayer
);
//---------------------------------------------------------------------------------------------------------------------
// GeoQMapsTiledServiceLayer geoQMapsTiledServiceLayer = new GeoQMapsTiledServiceLayer(GeoQMapLayerTypes.ChinaOnlineCommunity_Mobile);
...
...
app/src/main/java/com/pashanhoo/landsurvey/layers/baidu/BaiduMapsTiledServiceLayer.java
View file @
4a92846
...
...
@@ -133,29 +133,29 @@ public class BaiduMapsTiledServiceLayer extends TiledServiceLayer {
@SuppressLint
(
"DefaultLocale"
)
protected
byte
[]
getTile
(
int
level
,
int
col
,
int
row
)
throws
Exception
{
byte
[]
result
=
null
;
Log
.
i
(
"baidu"
,
level
+
"/"
+
col
+
"/"
+
row
);
String
url
=
""
;
String
s
=
"Galil"
;
int
offsetV
=
(
int
)
(
Math
.
pow
(
2
,
level
-
1
));
switch
(
baiduMapLayerTypes
)
{
case
BAIDU_VECTOR:
int
offsetV
=
(
int
)
(
Math
.
pow
(
2
,
level
-
1
));
url
=
"http://online"
+
((
col
+
row
)
%
8
+
1
)
+
".map.bdimg.com/onlinelabel/?qt=tile"
+
"&x="
+
(
col
-
offsetV
)
+
"&y="
+
(
offsetV
-
row
-
1
)
+
"&z="
+
level
+
"&styles=
s
l"
;
+
"&styles=
p
l"
;
break
;
case
BAIDU_IMAGE:
int
offsetI
=
(
int
)
(
Math
.
pow
(
2
,
level
-
1
));
url
=
"http://online"
+
((
col
+
row
)
%
8
+
1
)
+
".map.bdimg.com/onlinelabel/?qt=tile"
+
"&x="
+
(
col
-
offset
I
)
+
"&y="
+
(
offsetI
-
row
-
1
)
+
"&z="
+
level
+
"&styles=
p
l"
;
+
"&x="
+
(
col
-
offset
V
)
+
"&y="
+
(
offsetV
-
row
-
1
)
+
"&z="
+
level
+
"&styles=
s
l"
;
break
;
case
BAIDU_ROAD:
url
=
"http://webst02.is.autonavi.com/appmaptile?style=8&x="
+
col
+
"&y="
+
row
+
"&z="
+
level
;
url
=
"http://shangetu"
+
((
col
+
row
)
%
8
+
1
)
+
".map.bdimg.com/it/u="
+
"x="
+
(
col
-
offsetV
)
+
";y="
+
(
offsetV
-
row
-
1
)
+
";z="
+
level
+
";v=009;type=sate&fm=46"
;
break
;
case
BAIDU_TRAFFIC:
int
offsetT
=
(
int
)
(
Math
.
pow
(
2
,
level
-
1
));
url
=
"http://its.map.baidu.com:8002/traffic/TrafficTileService?"
+
"level="
+
level
+
"&x="
+
(
col
-
offset
T
)
+
"&y="
+
(
offsetT
-
row
-
1
)
+
"level="
+
level
+
"&x="
+
(
col
-
offset
V
)
+
"&y="
+
(
offsetV
-
row
-
1
)
+
"&time="
+
System
.
currentTimeMillis
();
break
;
}
...
...
app/src/main/java/com/pashanhoo/landsurvey/layers/gaode/GaodeMapsTiledServiceLayer.java
View file @
4a92846
...
...
@@ -138,11 +138,11 @@ public class GaodeMapsTiledServiceLayer extends TiledServiceLayer {
String
s
=
"Galil"
;
switch
(
gaodeMapLayerTypes
)
{
case
AMAP_VECTOR:
url
=
"http://webrd01.is.autonavi.com/appmaptile?&x="
+
col
+
"&y="
+
row
+
"&z="
+
level
+
url
=
"http://webrd01.is.autonavi.com/appmaptile?&x="
+
col
+
"&y="
+
row
+
"&z="
+
level
+
"&lang=zh_cn&size=1&scale=1&style=7"
;
break
;
case
AMAP_IMAGE:
url
=
"http://webst02.is.autonavi.com/appmaptile?style=6&x="
+
col
+
"&y="
+
row
+
"&z="
+
level
;
url
=
"http://webst02.is.autonavi.com/appmaptile?style=6&x="
+
col
+
"&y="
+
row
+
"&z="
+
level
;
break
;
case
AMAP_ROAD:
url
=
"http://webst02.is.autonavi.com/appmaptile?style=8&x="
+
col
+
"&y="
+
row
+
"&z="
+
level
;
...
...
app/src/main/java/com/pashanhoo/landsurvey/layers/google/GoogleMapsTiledServiceLayer.java
View file @
4a92846
...
...
@@ -130,7 +130,6 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer {
@SuppressLint
(
"DefaultLocale"
)
protected
byte
[]
getTile
(
int
level
,
int
col
,
int
row
)
throws
Exception
{
byte
[]
result
=
null
;
String
url
=
""
;
String
s
=
"Galil"
;
switch
(
googleMapLayerType
)
{
...
...
@@ -145,13 +144,11 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer {
break
;
case
IMAGE_ANNO_GOOGLE_MAP:
url
=
"http://mt"
+
(
col
%
4
)
+
".google.cn/vt/lyrs=s@131,h@209000000&hl=zh-CN&gl=CN&src=app&"
+
"x="
+
col
+
"&"
+
"y="
+
row
+
"&"
+
"z="
+
level
+
"&"
+
"s="
+
s
;
// url = "http://webst02.is.autonavi.com/appmaptile?style=8&x=" + col + "&y=" + row + "&z=" + level;
break
;
case
OSM_Map:
url
=
"https://c.tile.openstreetmap.org/"
+
level
+
"/"
+
col
+
"/"
+
row
+
".png"
;
break
;
}
try
{
// 首先从离线数据库中读取
result
=
getOfflineCacheDB
(
level
,
col
,
row
);
...
...
app/src/main/java/com/pashanhoo/landsurvey/layers/tencent/TencentMapLayerTypes.java
0 → 100644
View file @
4a92846
package
com
.
pashanhoo
.
landsurvey
.
layers
.
tencent
;
import
com.pashanhoo.landsurvey.layers.BaseTiledMapServiceType
;
public
enum
TencentMapLayerTypes
implements
BaseTiledMapServiceType
{
/**
* 百度矢量图层(含路网,含注记)
*/
TENCENT_MAP_VECTOR
,
TENCENT_MAP_VECTOR_NIGHT
,
/**
* 百度影像图层(不含路网,不含注记)
*/
TENCENT_MAP_IMAGE
,
/**
* 百度路网图层(含路网,含注记)
*/
TENCENT_MAP_ROAD
,
/**
* 百度实时交通图层
*/
TENCENT_MAP_TERRAIN
;
@Override
public
String
getName
()
{
return
this
.
name
().
toString
();
}
}
app/src/main/java/com/pashanhoo/landsurvey/layers/tencent/TencentMapsTiledServiceLayer.java
0 → 100644
View file @
4a92846
package
com
.
pashanhoo
.
landsurvey
.
layers
.
tencent
;
import
android.annotation.SuppressLint
;
import
android.content.ContentValues
;
import
android.database.Cursor
;
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.Point
;
import
com.esri.core.geometry.SpatialReference
;
import
com.esri.core.internal.io.handler.ResponseListener
;
import
com.esri.core.internal.io.handler.a
;
import
com.esri.core.io.UserCredentials
;
import
com.pashanhoo.landsurvey.utils.AppInfo
;
import
com.pashanhoo.landsurvey.utils.GADBHelper
;
import
java.util.concurrent.RejectedExecutionException
;
/**
* Created by jiangbotao on 2018/3/28.
*/
public
class
TencentMapsTiledServiceLayer
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
[]
res
=
{
156543.03392800014
,
78271.516963999937
,
39135.758482000092
,
19567.879240999919
,
9783.9396204999593
,
4891.9698102499797
,
2445.9849051249898
,
1222.9924525624949
,
611.49622628138
,
305.748113140558
,
152.874056570411
,
76.4370282850732
,
38.2185141425366
,
19.1092570712683
,
9.55462853563415
,
4.7773142679493699
,
2.3886571339746849
,
1.1943285668550503
,
0.59716428355981721
,
0.29858214164761665
};
private
static
final
double
[]
scale
=
{
591657527.591555
,
295828763.79577702
,
147914381.89788899
,
73957190.948944002
,
36978595.474472001
,
18489297.737236001
,
9244648.8686180003
,
4622324.4343090001
,
2311162.217155
,
1155581.108577
,
577790.554289
,
288895.277144
,
144447.638572
,
72223.819286
,
6111.909643
,
18055.954822
,
9027.9774109999998
,
4513.9887049999998
,
2256.994353
,
1128.4971760000001
};
private
static
String
URL
=
"http://maps.iwxlh.com"
;
private
ResponseListener
responseListener
;
private
static
Point
origin
=
new
Point
(-
20037508.342787
,
20037508.342787
);
private
TencentMapLayerTypes
tencentMapLayerTypes
;
public
TencentMapsTiledServiceLayer
(
TencentMapLayerTypes
layerType
)
{
this
(
true
);
this
.
tencentMapLayerTypes
=
layerType
;
// 新建数据表,主要在Activity中必须有AppInfo.Settings()初始数据库
GADBHelper
.
createTable
(
AppInfo
.
mapcachedb
,
this
.
tencentMapLayerTypes
.
getName
());
}
public
TencentMapsTiledServiceLayer
(
boolean
initLayer
)
{
super
(
URL
);
this
.
isBingMap
=
true
;
if
(!(
initLayer
))
return
;
try
{
getServiceExecutor
().
submit
(
new
Runnable
()
{
public
void
run
()
{
TencentMapsTiledServiceLayer
.
this
.
initLayer
();
}
});
}
catch
(
RejectedExecutionException
localRejectedExecutionException
)
{
Log
.
e
(
"ArcGIS"
,
"initialization of the layer failed."
,
localRejectedExecutionException
);
}
}
public
static
double
[]
getRes
()
{
return
res
;
}
protected
void
initLayer
()
{
if
(
getID
()
==
0L
)
{
this
.
nativeHandle
=
create
();
}
if
(
getID
()
==
0L
)
{
this
.
changeStatus
(
OnStatusChangedListener
.
STATUS
.
fromInt
(-
1000
));
}
else
{
try
{
this
.
setDefaultSpatialReference
(
SpatialReference
.
create
(
102100
));
this
.
setFullExtent
(
new
Envelope
(
xmin
,
ymin
,
xmax
,
ymax
));
this
.
setTileInfo
(
new
TileInfo
(
origin
,
scale
,
res
,
scale
.
length
,
96
,
256
,
256
));
super
.
initLayer
();
}
catch
(
Exception
localException
)
{
this
.
changeStatus
(
OnStatusChangedListener
.
STATUS
.
fromInt
(-
1005
));
Log
.
e
(
"ArcGIS"
,
"Bing map url ="
+
getUrl
(),
localException
);
}
}
}
@SuppressLint
(
"DefaultLocale"
)
protected
byte
[]
getTile
(
int
level
,
int
col
,
int
row
)
throws
Exception
{
byte
[]
result
=
null
;
String
url
=
""
;
String
s
=
"Galil"
;
row
=
(
int
)
Math
.
pow
(
2
,
level
)
-
1
-
row
;
switch
(
tencentMapLayerTypes
)
{
case
TENCENT_MAP_VECTOR:
url
=
"http://rt"
+
(
col
%
4
)
+
".map.gtimg.com/tile?"
+
"z="
+
level
+
"&x="
+
col
+
"&y="
+
row
+
"&type=vector&styleid=0"
;
break
;
case
TENCENT_MAP_IMAGE:
url
=
"http://p"
+
(
col
%
4
)
+
".map.gtimg.com/sateTiles/"
+
level
+
"/"
+
(
int
)
Math
.
floor
(
col
/
16
)
+
"/"
+
(
int
)
Math
.
floor
(
row
/
16
)
+
"/"
+
col
+
"_"
+
row
+
".jpg"
;
break
;
case
TENCENT_MAP_ROAD:
url
=
"http://rt"
+
(
col
%
4
)
+
".map.gtimg.com/tile?"
+
"z="
+
level
+
"&x="
+
col
+
"&y="
+
row
+
"&type=vector&styleid=3"
;
break
;
case
TENCENT_MAP_TERRAIN:
url
=
"http://p"
+
(
col
%
4
)
+
".map.gtimg.com/demTiles/"
+
level
+
"/"
+
(
int
)
Math
.
floor
(
col
/
16
)
+
"/"
+
(
int
)
Math
.
floor
(
row
/
16
)
+
"/"
+
col
+
"_"
+
row
+
".jpg"
;
break
;
case
TENCENT_MAP_VECTOR_NIGHT:
url
=
"http://rt"
+
(
col
%
4
)
+
".map.gtimg.com/tile?"
+
"z="
+
level
+
"&x="
+
col
+
"&y="
+
row
+
"&type=vector&styleid=4"
;
break
;
}
try
{
// 首先从离线数据库中读取
result
=
getOfflineCacheDB
(
level
,
col
,
row
);
// 如果没有就直接从web上读取
if
(
result
==
null
)
{
result
=
a
.
a
(
url
,
null
,
null
,
this
.
responseListener
);
// 将读取的数据存入mbtiles中
AddOfflineCacheDB
(
level
,
col
,
row
,
result
);
}
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
return
result
;
}
public
void
refresh
()
{
try
{
getServiceExecutor
().
submit
(
new
Runnable
()
{
public
void
run
()
{
if
(!(
TencentMapsTiledServiceLayer
.
this
.
isInitialized
()))
return
;
try
{
TencentMapsTiledServiceLayer
.
this
.
clearTiles
();
}
catch
(
Exception
localException
)
{
Log
.
e
(
"ArcGIS"
,
"Re-initialization of the layer failed."
,
localException
);
}
}
});
}
catch
(
RejectedExecutionException
localRejectedExecutionException
)
{
return
;
}
}
public
void
reinitializeLayer
(
UserCredentials
usercredentials
)
{
}
public
void
reinitializeLayer
(
String
appID
)
{
super
.
reinitializeLayer
(
null
);
}
private
byte
[]
getOfflineCacheDB
(
int
level
,
int
col
,
int
row
)
throws
Exception
{
byte
[]
result
=
null
;
String
sql
=
"select * from "
+
this
.
tencentMapLayerTypes
.
getName
()
+
" where TILELEVEL = "
+
level
+
" and TILECOL = "
+
col
+
" and TILEROW = "
+
row
;
Cursor
mCursor
=
AppInfo
.
mapcachedb
.
rawQuery
(
sql
,
null
);
boolean
hasData
=
false
;
while
(
mCursor
.
moveToNext
())
{
//判断是否存在数据
hasData
=
true
;
}
if
(
hasData
)
{
//数据库中有数据
try
{
if
(
mCursor
.
moveToFirst
())
{
result
=
mCursor
.
getBlob
(
mCursor
.
getColumnIndex
(
"TILEDATA"
));
}
mCursor
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
result
=
null
;
}
}
return
result
;
}
private
void
AddOfflineCacheDB
(
int
level
,
int
col
,
int
row
,
byte
[]
bytes
)
{
ContentValues
values
=
new
ContentValues
();
values
.
put
(
"TILELEVEL"
,
level
);
values
.
put
(
"TILECOL"
,
col
);
values
.
put
(
"TILEROW"
,
row
);
values
.
put
(
"TILEDATA"
,
bytes
);
AppInfo
.
mapcachedb
.
insert
(
this
.
tencentMapLayerTypes
.
getName
(),
null
,
values
);
}
}
Please
register
or
sign in
to post a comment