Issue
In my app, I am setting (online) source of tiles based on user's choice in the preferences (there are only 2 options possible - UMP and default, i.e. OpenStreetMaps). Here is how I change source of the tiles from the default:
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
if (prefs.getString("map_source_preference", "osm") == "ump") {
final MapTileProviderBasic tileProvider = new MapTileProviderBasic(
getApplicationContext());
final ITileSource tileSource = new XYTileSource("UMP Tiles", null,
3, 14, 256, ".png", "http://tiles.ump.waw.pl/ump_tiles/");
tileProvider.setTileSource(tileSource);
final TilesOverlay tilesOverlay = new TilesOverlay(tileProvider,
this.getBaseContext());
mapView.getOverlays().add(tilesOverlay);
}
My question is: how do I set tile provider back to the OSMDroid's default? Would tileProvider.detach()
work in this case?
Solution
You don't want to create a new TilesOverlay when you change ITileSource. You can call
mapView.setTileSource(tileSource);
and that will apply your new tile source to the existing TilesOverlay.
If you wanted to go back to the default tile source you can call
mapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
Answered By - kurtzmarc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.