I want to hide the base map in google map v2 Because I added Tile Overlay from osmdroid to Google Map This is my code:
mMap = googleMap;
mMap.setMyLocationEnabled(false);
mMap.getUiSettings().setZoomControlsEnabled(false);
mMap.getUiSettings().setMyLocationButtonEnabled(false);
mMap.getUiSettings().setMapToolbarEnabled(false);
mMap.getUiSettings().setCompassEnabled(false);
mMap.setMaxZoomPreference(19);
String mUrl = "https://a.tile.openstreetmap.org/{z}/{x}/{y}.png";
MyUrlTileProvider mTileProvider = new MyUrlTileProvider(256, 256, mUrl);
mMap.addTileOverlay(new TileOverlayOptions().tileProvider(mTileProvider).zIndex(0));
But when zoom_in or zoom_out, it first loads the tile from Google Maps and then loads the tile from osm. I want the base map of the show to be hidden and only the tiles to be loaded from osmdroid.
Easiest way is to use GoogleMap.setMapType()
method and set map type to MAP_TYPE_NONE:
@Override
public void onMapReady(GoogleMap googleMap) {
googleMap.setMapType(GoogleMap.MAP_TYPE_NONE);
...
}
But also you can create custom GroundOverlay
which is solid color bitmap filled by desired background color and place it exactly at current screen view (details you can find e.g this answer), or even create custom MapView
-based component and override its onDraw()
method and use Canvas
object to fill it with solid color (e.g. white):
...
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(Color.WHITE);
}
...