Use offline maps (cache) in the Google Maps API for Android

Google Maps offers for several months the function of downloading a specific geographic region for later offline use. I use the Google Maps API for Android in my application, and I see that offline, unlike the real Google maps application, I can’t fully zoom in on the street in my application, so the downloaded data is probably not used.

Is there any way to use my application?

+4
source share
1 answer

You need to create your own TileProviderand locally access the tiles. Check the documentation .

Here are some related topics that may help you:

Check out this video tutorial on caching and this example from 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

, !

+5

All Articles