【问题标题】:Offline google maps with .mbtiles带有 .mbtiles 的离线谷歌地图
【发布时间】:2016-01-18 20:18:05
【问题描述】:

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

【问题讨论】:

    标签: android google-maps google-maps-api-3 tiles mbtiles


    【解决方案1】:

    这个库就是你需要的 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();
    

    【讨论】:

    • 我已经尝试过了,但我自己没有任何成功。
    • 请注意,这个 sn-p 不仅仅是一个 copy-paste-magic 你应该阅读和做 cmets,它已经为我工作了三年多
    猜你喜欢
    • 2014-12-21
    • 2012-10-26
    • 2017-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多