public class GoogleMapUtil {
final static String url = "http://mt2.google.cn/vt/lyrs=y@167000000&hl=zh-CN&gl=cn&x=%d&y=%d&z=%d&s=Galil";
public static TileOverlayOptions getGooleMapTileOverlayOptions() {
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;
}
};
return new TileOverlayOptions()
.tileProvider(tileProvider)
.diskCacheEnabled(true)
.diskCacheSize(100000)
.diskCacheDir(Configuration.getAppContext().getExternalCacheDir().getAbsolutePath())
.memoryCacheEnabled(false)
.zIndex(-9999);
}
}
调用加入即可接入谷歌地图
aMap.addTileOverlay(GoogleMapUtil.getGooleMapTileOverlayOptions());
这种方式会导致底层为高德地图,上层为谷歌地图,消耗过多流量和内存,也可以用arcGis来实现。