在Google Maps Android API中使用谷歌地图离线地图(缓存)

在Google Maps Android API中使用谷歌地图离线地图(缓存),第1张

概述Google地图提供了几个月的功能,可以下载某个地理区域供以后离线使用.我在我的应用程序中使用谷歌地图AndroidAPI,我发现在离线时,与真正的谷歌地图应用程序相比,我无法完全放大到我的应用程序中的街道级别,因此可能不会使用下载的数据.有没有办法让我的应用程序使用它?解决方法:您

Google地图提供了几个月的功能,可以下载某个地理区域供以后离线使用.我在我的应用程序中使用谷歌地图Android API,我发现在离线时,与真正的谷歌地图应用程序相比,我无法完全放大到我的应用程序中的街道级别,因此可能不会使用下载的数据.

有没有办法让我的应用程序使用它?

解决方法:

您需要在本地创建自己的TileProvider并访问磁贴.检查这个documentation.

以下是一些可能对您有帮助的相关主题:

> Using the android Google Maps API v2 as a viewer of offline tiles: is it possible?
> Offline mode for android app using google maps api
> TileProvider using local tiles

检查video tutorial about caching和example from GitHub.

你也可以使用osmdroid,它取代了AndroID的MapVIEw类.它还包括一个模块化磁贴提供程序系统,支持众多在线和离线磁贴源以及内置叠加层的叠加支持,用于绘制图标,跟踪位置和绘图形状.这是tutorial.

org.osmdroID.vIEws.MapVIEw mapVIEw = (org.osmdroID.vIEws.MapVIEw) findVIEwByID(R.ID.map_vIEw); //resolve the map vIEw by ID given in the layoutmapVIEw.setTileSource(new OnlineTileSourceBase("Google Maps", ResourceProxy.string.unkNown, 1, 20, 256, ".png", "http://mt3.Google.com/vt/v=w2.97") {       @OverrIDe    public String getTileURLString(final MapTile aTile) {        /*         * Google MAPS URL looks like         *  base url        const   x   y    zoom         * http://mt3.Google.com/vt/v=w2.97&x=74327&y=50500&z=17         */        return getBaseUrl() + "&x=" + aTile.getX() + "&y=" + aTile.getY() + "&z=" + aTile.getZoomLevel();    }});mapVIEw.setUseDataConnection(false); //this actually makes the controller use only offline tiles

希望这可以帮助!

总结

以上是内存溢出为你收集整理的在Google Maps Android API中使用谷歌地图离线地图(缓存)全部内容,希望文章能够帮你解决在Google Maps Android API中使用谷歌地图离线地图(缓存)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1098300.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存