Setting min and max zoom levels
Asked Answered
B

1

2

Having trouble with the zoom interface using OSMDroid API- can not seem to get the zoom control to zoom beyond level 18. Using a local ( SD card ) custom map cache with levels 12-22. We can zoom from 12 -18, but not beyond. There doesn't seem to be any way to set the min or max zoom. Anyone have any ideas on where this setting is defined?

Bellarmine answered 25/4, 2013 at 19:8 Comment(0)
B
4

You need to make a class extending MapView, there you can set it by overriding the getMaxZoomLevel() and getMinZoomLevel(), like this:

public class CustomMapView extends MapView {

/* constructors */  

@Override
public int getMaxZoomLevel() {
    return 22;
}

@Override
public int getMinZoomLevel() {
    return 12;
}

}

don't forget to change the MapView call to CustomMapView in your layout:

<com.yourpackage.CustomMapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

and activity:

private CustomMapView mMapView;
.
.
.
mMapView = (CustomMapView) findViewById(R.id.mapview);
Bussard answered 3/5, 2013 at 5:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.