Android Google Maps: disable dragging in MapFragment

36,935

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);
Share:
36,935
Mahe
Author by

Mahe

Updated on July 08, 2022

Comments

  • Mahe
    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
    Mahe almost 11 years
    Thanks! That's the great help!!
  • Uzair Qaiser
    Uzair Qaiser over 5 years
    second 1 about zoom, was usefull. +1
  • mrisek
    mrisek almost 5 years
    Link is broken.
  • jeprubio
    jeprubio almost 5 years
  • Mujahid Khan
    Mujahid Khan almost 4 years