I'm trying to build a Map with custom tiles using the Google Maps Android SDK. I've checked out the TileOverlayDemoActivity of the android-samples Github repository.
According to the documentation at Zoom level 0 a single image will be requested, on zoom level 1 a total of 4 images and so on. Currently I'm facing the problem that immediately after loading the map the TileProvider#getTitle
is getting called with zoom level 3 and there is no way for me to zoom out. Even if I display the zoom controls the "-" is disabled.
What I have tried
I figured it might be related to the Camera
so I tried calling the following
map.moveCamera(CameraUpdateFactory.zoomTo(0.0f));
Unfortunately this doesn't have any effect. Same goes for the following
map.setMinZoomPreference(0);
Currently I don't know what the issue might be.
Following my code. It's basically the same as in the linked demo activity I've just changed the UrlTileProvider
to my own.
@Override
public void onMapReady(GoogleMap map) {
map.setMapType(GoogleMap.MAP_TYPE_NONE);
map.setMinZoomPreference(0);
map.getUiSettings().setZoomControlsEnabled(true);
map.moveCamera(CameraUpdateFactory.zoomTo(0.0f));
TileProvider tileProvider = new TileProvider() {
@Override
public Tile getTile(int x, int y, int zoom) {
String name = "tile_" + Integer.toString(zoom) + "_" + Integer.toString(x) + "_" + Integer.toString(y);
Resources resources = getResources();
final int resourceId = resources.getIdentifier(name, "drawable", getPackageName());
Drawable d = getResources().getDrawable(resourceId);
Bitmap bitmap = ((BitmapDrawable) d).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] bitmapdata = stream.toByteArray();
return new Tile(256, 256, bitmapdata);
}
};
mapTiles = map.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider));
}
Maybe it's worth mentioning what map.getCameraPosition()
returns:
CameraPosition{target=lat/lng: (0.0,0.0), zoom=2.0, tilt=0.0, bearing=0.0}
tl;dr
How can I set the Map to zoom level 0?
Edit
According to the comment and answer I tried to activate Lite Mode
and set the zoom level via XML:
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraZoom="1"
map:mapType="normal"
class="com.google.android.gms.maps.SupportMapFragment" />
Unfortunately without any effect. It still starts requesting at zoom level 3.