Googleの地図はハイドアプリのtileoverlay層を使って表示されます。
1710 ワード
private void init() {
if (aMap == null) {
aMap = mapView.getMap();
setUpMap();
TileOverlay tileOverlay;
final String url = "http://mt0.google.cn/vt/lyrs=y@198&hl=zh-CN&gl=cn&src=app&x=%d&y=%d&z=%d&s=";
TileProvider tileProvider = new UrlTileProvider(256, 256) {
public URL getTileUrl(int x, int y, int zoom) {
try {
return new URL(String.format(url, x, y, zoom));
} catch (MalformedURLException e) {
e.printStackTrace();
}
return null;
}
};
if (tileProvider != null) {
tileOverlay = aMap.addTileOverlay(new TileOverlayOptions()
.tileProvider(tileProvider)
.diskCacheEnabled(true)
.diskCacheDir("/storage/emulated/0/amap/cache")
.diskCacheSize(100000)
.memoryCacheEnabled(true)
.memCacheSize(100000))
;
}
}
}
そのうちurl=http://mt0.google.cn/vt/lyrs=y@198&hl=zh-CSN&gl=cn&src=ap&x=%d&y=%d&z=;mt 0は値mt 3を取ることができます
lyrs=yは混合地図で、sは衛星地図で、mは普通地図です。
利点:
1、壁にかかっているGoogleの地図が表示されます。国内ではgoogleアプリが使えません。
2、正確さは測位誤差がないので、高徳を使ってSDKの位置付けができます。Googleが中国で使用しているのは高徳データ源と関係があるかもしれません。
短所:
1、下の図は高徳地図で、上の階はGoogle地図です。同時に二つの地図をロードして、システムの資源と流量を浪費します。
2、diskycacheは無効で、sdカードの中に瓦地図のキャッシュが見つからないので、memorycacheは有効で、メモリの中の瓦を迅速にロードすることができます。