Google Maps提供了几个月的功能,可以下载特定地理区域以供以后离线使用。我在我的应用程序中使用Google Maps Android API,并且看到离线状态下,与真正的google maps应用程序相比,我无法在应用程序中完全放大街道级别,因此可能不使用下载的数据。
我的应用程序可以利用它吗?
您需要创建自己的TileProvider
并在本地访问图块。检查此文档。
以下是一些可以帮助您的相关主题:
查看有关缓存的视频教程以及来自GitHub的示例。
您也可以使用osmdroid,它是Android MapView类的替代品。它还包括一个模块化的图块提供程序系统,该系统提供对众多在线和离线图块源的支持,并通过内置的覆盖图(用于绘制图标,跟踪位置和绘制形状)来支持覆盖图。这是本教程。
org.osmdroid.views.MapView mapView = (org.osmdroid.views.MapView) findViewById(R.id.map_view); //resolve the map view by id given in the layout
mapView.setTileSource(new OnlineTileSourceBase("Google Maps", ResourceProxy.string.unknown, 1, 20, 256, ".png", "http://mt3.google.com/vt/v=w2.97") {
@Override
public String getTileURLString(final MapTile aTile) {
/*
* GOOGLE MAPS URL looks like
* base url const x y zoom
* http://mt3.google.com/vt/v=w2.97&x=74327&y=50500&z=17
*/
return getBaseUrl() + "&x=" + aTile.getX() + "&y=" + aTile.getY() + "&z=" + aTile.getZoomLevel();
}
});
mapView.setUseDataConnection(false); //this actually makes the controller use only offline tiles
希望这可以帮助!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句