I have mbtiles file and I need to implement it into my google maps view in android. I cannot find a suitable tutorial for this, so, if anyone has something to offer, please share it with me...
Asked
Active
Viewed 2,547 times
1 Answers
1
This library is what you need https://github.com/cocoahero/android-gmaps-addons
use this snippet after adding library to you project:
// Retrieve GoogleMap instance from MapFragment or elsewhere
GoogleMap map;
// Create new TileOverlayOptions instance.
TileOverlayOptions opts = new TileOverlayOptions();
// Get a File reference to the MBTiles file.
File myMBTiles;
// Create an instance of MapBoxOfflineTileProvider.
MapBoxOfflineTileProvider provider = new MapBoxOfflineTileProvider(myMBTiles);
// Set the tile provider on the TileOverlayOptions.
opts.tileProvider(provider);
// Add the tile overlay to the map.
TileOverlay overlay = map.addTileOverlay(opts);
// Sometime later when the map view is destroyed, close the provider.
// This is important to prevent a leak of the backing SQLiteDatabase.
provider.close();

Muhammad Naderi
- 3,090
- 3
- 24
- 37
-
I've tried this and haven't had any success myself. – Jordan Réjaud Sep 18 '17 at 20:45
-
please notice that, this snippet is not just a `copy-paste-magic` you should read and do the comments, it has been working for me, for more than three years – Muhammad Naderi Dec 26 '18 at 05:46