0

我有 mbtiles 文件,我需要将它实现到我在 android 中的谷歌地图视图中。我找不到合适的教程,所以,如果有人可以提供一些东西,请与我分享...

4

1 回答 1

1

这个库就是你需要的 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();
于 2016-12-28T07:56:39.180 回答