Android Google Maps: disable dragging in MapFragment
Solution 1
I think here's what you're looking for:
Inside Google Maps Android v2
Scroll (pan) gestures
A user can scroll (pan) around the map by dragging the map with their finger. You can disable scrolling by calling UiSettings.setScrollGesturesEnabled(boolean).
Solution 2
You can disable dragging in MapFragment
using:
googleMap.getUiSettings().setScrollGesturesEnabled(false);
Solution 3
for disable dragging in MapFragment
this code :
googleMap.getUiSettings().setScrollGesturesEnabled(false);
works as @tomrozb said. but it dosn't disable map zoom by touch on map. for that use this code beside above code:
googleMap.getUiSettings().setZoomGesturesEnabled(false);
Solution 4
you can use isScrollGesturesEnabled for map
java:
googleMap.getUiSettings().setZoomGesturesEnabled(false)
;
kotlin
googleMap?.uiSettings?.isScrollGesturesEnabled = false
Solution 5
You can disable dragging in MapFragment using:
mMap.getUiSettings().setScrollGesturesEnabled(false);
mMap.getUiSettings().setZoomGesturesEnabled(false);
mMap.getUiSettings().setScrollGesturesEnabledDuringRotateOrZoom(false);
Mahe
Updated on July 08, 2022Comments
-
Mahe almost 2 years
Can I disable drag functionality when the user tries to drag the map with his fingers without disturbing the Zoom in and Zoom out?
Any one please suggest an idea of doing this! Thanks for your Precious help!!
-
Mahe almost 11 yearsThanks! That's the great help!!
-
Uzair Qaiser over 5 yearssecond 1 about zoom, was usefull. +1
-
mrisek almost 5 yearsLink is broken.
-
jeprubio almost 5 years
-
Mujahid Khan almost 4 yearsTry this : stackoverflow.com/a/60665420/7135685