Setting min and max zoom levels

喜夏-厌秋 提交于 2019-12-06 12:03:04

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