在Google地图AndroidAPI中使用google地图离线地图(缓存)

Use google maps offline maps (cache) in Google Maps Android API

Google 地图提供了几个月的下载特定地理区域供以后离线使用的功能。我在我的应用程序中使用 Google 地图 Android API 并且我在离线时看到它,与真正的 google 地图应用程序形成对比,我无法在我的应用程序中完全放大到街道级别,因此可能未使用下载的数据。

我的应用程序可以使用它吗?

您需要创建自己的 TileProvider and access tiles locally. Check this documentation

以下是一些可能对您有所帮助的相关话题:

  • Using the android Google Maps API v2 as a viewer of offline tiles: is it possible?
  • Offline mode for android app using google maps api
  • TileProvider using local tiles

检查此 video tutorial about caching and this example from GitHub

您也可以使用osmdroid which is a replacement for Android's MapView class. It also includes a modular tile provider system with support for numerous online and offline tile sources and overlay support with built-in overlays for plotting icons, tracking location, and drawing shapes. Here is the tutorial

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

希望对您有所帮助!