Override MapView Tile Source?

£可爱£侵袭症+ 提交于 2020-01-12 13:49:12

问题


Is it possible to override the source of the tiles that the Android MapView displays?

I have some map imagery tiles in a database, and would like to use the Google maps MapView to look at them.

Also, if this is not possible... does anyone know of a MapView that does allow this? (OpenStreetMap API... MapQuest API... etc)

I am looking for a solution that does not rely on the GPL/LGPL.


回答1:


You can use some of these libraries: osmdroid, mapsforge. Both of them provides interface to some internet map databases and allows to create your own maps provider.

They allows you to have (and handle) your offline cache, dynamic asynchronous maps loading, resampling on zoom, adding overlays and so on, like original MapView does. Another good point of using these libraries is that they are well-designed for in-place substitution of google MapView.

Also you may be interested in Google's Javascript maps api, which also allows to use custom maps source (see this link). This approach can be used with loading map into your WebView. But in this case you still need Google's Maps API key and I'm afraids that you'll be still limited to 25000 usages per day.

== UPDATE ==

Now, Google Maps for Android (that one in Google Play Services) support custom tiles, so there is no more need to use 3rd-party libraries for applying you own tiles (if the usage meets license agreement).




回答2:


You can create a TileProvider to return tiles to the Maps API. Then use setMapType to set MAP_TYPE_NONE, and only the tiles you provide will be visible. I know this can be done for a MapFragment, but have not tried it with a MapView.

See the sample code from Google in MapDemo TileOverlayDemo for an example.



来源:https://stackoverflow.com/questions/9213152/override-mapview-tile-source

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!