【发布时间】:2016-01-18 20:18:05
【问题描述】:
我有 mbtiles 文件,我需要在我的 android 谷歌地图视图中实现它。我找不到合适的教程,所以,如果有人可以提供一些东西,请与我分享...
【问题讨论】:
标签: android google-maps google-maps-api-3 tiles mbtiles
我有 mbtiles 文件,我需要在我的 android 谷歌地图视图中实现它。我找不到合适的教程,所以,如果有人可以提供一些东西,请与我分享...
【问题讨论】:
标签: android google-maps google-maps-api-3 tiles mbtiles
这个库就是你需要的 https://github.com/cocoahero/android-gmaps-addons
在将库添加到您的项目后使用此 sn-p:
// 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();
【讨论】:
copy-paste-magic 你应该阅读和做 cmets,它已经为我工作了三年多