How can you disable pinch or multitouch functionality in an Android MapView?
Asked
Active
Viewed 6,678 times
4 Answers
9
Disable all Gestures:
mapView.getMap().getUiSettings().setAllGesturesEnabled(false);
Disable just Zoom
mapView.getMap().getUiSettings().setZoomControlsEnabled(false);

Taranfx
- 10,361
- 17
- 77
- 95
8
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;
}
});

Alexander Stolz
- 7,454
- 12
- 57
- 64
-
I found out that when you use `mapView.setBuiltInZoomControls(true);`, `onTouch()` is only called once (the first time), so this method is useless... Do you think it's a MapView bug? – Murphy Apr 20 '11 at 23:37
-
I can't really tell. In my application I had setBuiltInZoomControls on false and implemented my own controls. – Alexander Stolz May 27 '11 at 08:43
-
1i have tried this, it does not work if you are using built in zoom controls – user590849 Aug 26 '11 at 11:54
-
there has to be another solution for this – user590849 Aug 26 '11 at 11:54
-
2+1 Yes this is the one! It gets called on my device every time the user attempts to use two fingers to do ... well whatever :). Thanks to this solution tapping still works - Great ! – AgentKnopf Apr 21 '12 at 20:54
-
yea this is the only way to do it. – gregm Jul 23 '12 at 18:04
1
final UiSettings uiSettings = map.getUiSettings();
uiSettings.setZoomControlsEnabled(true);
uiSettings.setZoomGesturesEnabled(false);

Mark Pazon
- 6,167
- 2
- 34
- 50
-2
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

Yamu
- 1,652
- 10
- 15