0

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...

Miljan Vulovic
  • 1,586
  • 3
  • 20
  • 48

1 Answers1

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