我有mbtiles文件,我需要在android中的谷歌地图视图中实现它。我找不到合适的教程,所以,如果有人提供的东西,请与我分享......
答案 0 :(得分:0)
这个库就是您所需要的 https://github.com/cocoahero/android-gmaps-addons
在向您的项目添加库后使用此代码段:
// 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();