Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable google maps dragging

Tags:

google-maps

How to disable the dragging in google maps in your website in order to freeze it like an image? I've just used basic Iframe code that gives me google maps.

like image 730
phpguest Avatar asked Sep 25 '13 18:09

phpguest


People also ask

How do I stop my maps from moving on Android?

A user can scroll (pan) around the map by dragging the map with their finger. You can disable scrolling by calling UiSettings. setScrollGesturesEnabled(boolean).

How do I drag a country into Google Maps?

To get an overlay for a landmass, type the name of a state or country in the box in the top left corner of the site and choose the country from the matching list of names. The landmass will be dropped onto the map. You can move the landmass by clicking on it, holding down the mouse button, and dragging.


2 Answers

You can set draggable: false in the setOptions() method on your map object:

map.setOptions({draggable: false});

More here.(Ctrl + f and search 'draggable')

like image 53
MattSull Avatar answered Oct 18 '22 20:10

MattSull


The draggable property has been deprecated.

To disable dragging on the map, you can now use the gestureHandling property, and set it to "none".

You can also disable the use of arrow keys, by setting keyboardShortcuts to false

ex: map.setOptions({gestureHandling: "none", keyboardShortcuts: false});

like image 34
lfkwtz Avatar answered Oct 18 '22 19:10

lfkwtz