Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override MapView Tile Source?

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.

like image 406
Matt Avatar asked Feb 09 '12 14:02

Matt


2 Answers

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).

like image 140
OleGG Avatar answered Nov 16 '22 15:11

OleGG


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.

like image 24
Peter B Avatar answered Nov 16 '22 15:11

Peter B