How to disable pinch in Android MapView

这一生的挚爱 提交于 2019-11-27 16:21:19

It took me a little time but I have a solution for this. What I did is stop the event propagation if more than one finger is touching the screen.

mapView.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            if(event.getPointerCount() > 1) {
                return true;
            }
            return false;
        }
    });

Disable all Gestures:

mapView.getMap().getUiSettings().setAllGesturesEnabled(false);

Disable just Zoom

mapView.getMap().getUiSettings().setZoomControlsEnabled(false);
final UiSettings uiSettings = map.getUiSettings();
uiSettings.setZoomControlsEnabled(true);
uiSettings.setZoomGesturesEnabled(false);

Here is a little trick to fool pinch zoom :P (set a Zoom level and set the same level as maxZoom

var myOptions1 = { 
            //Coordinates of the map's center
            center: new google.maps.LatLng(152,125), 
            //Zoom level
            zoom: 15, // or any level of zoom you want to preload your map
            maxZoom:15 // same as the zoom value makes sure the map is not zoomed,

//Other options are as per your requirements

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