Setting min and max zoom levels

早过忘川 提交于 2019-12-22 13:51:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!