Google Maps Android MapView v2: disable zooming

∥☆過路亽.° 提交于 2019-12-01 00:02:52

问题


Is there a way to disable the zooming (pinch and double tap) in the MapView but keep the scrolling?

This means setting clickable to false would not work.

I have also tried setting an onTouch listener in the activity but it will not trigger using:

mapView.setOnTouchListener(this);

回答1:


You can assign those properties using the XML file:

   map:uiRotateGestures="true"
   map:uiScrollGestures="true"
   map:uiTiltGestures="true"
   map:uiZoomGestures="true"

So use:

   map:uiZoomGestures="false"

On the MapFragment object.




回答2:


import com.google.android.gms.maps.GoogleMap;

public void onMapReady(GoogleMap map) {
...
map.getUiSettings().setZoomGesturesEnabled(false);

UiSettings Documentation




回答3:


here is example on Kotlin:

map.uiSettings.setAllGesturesEnabled(false)



回答4:


U may also try some thing like that ..

NOTE : this method disables zoom in / out functionality for Google map UI

Above two answer is correct as per question asked. Thanks David for updating me.

GoogleMap myMap;

myMap.getUiSettings().setZoomControlsEnabled(false);

For more public methods available for Google Map UI ..

https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/UiSettings#setZoomControlsEnabled(boolean)



来源:https://stackoverflow.com/questions/15878616/google-maps-android-mapview-v2-disable-zooming

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