问题
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?
回答1:
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);
来源:https://stackoverflow.com/questions/16222825/setting-min-and-max-zoom-levels