Sami Al-Subhi
Sami Al-Subhi

Reputation: 4672

how to disable/enable dragging, zooming and change the cursor in Google maps v3

how can i disable/enable dragging, zooming in a 'map' object. also how can i change the cursor to for example a plus sign and then change it back to default.

I have tried these but doesn't work:

 map.google.maps.MapOptions.disableDoubleClickZoom = true;
map.google.maps.MapOptions.draggable = false;

Upvotes: 6

Views: 9861

Answers (2)

Guillermo G. Smitto
Guillermo G. Smitto

Reputation: 69

If you want to disable the most of the actions over the map use:

    mapOptions: {
    disableDefaultUI : true,
    clickableIcons: false,
    gestureHandling: 'none',
    draggableCursor: 'arrow' //use the arrow default pointer ;)
  }

Upvotes: 0

Tomas
Tomas

Reputation: 59575

You have two options how to set map options:

map = new google.maps.Map({ draggable : false }); // upon initialization
map.setOptions({ draggable : false }); // or in runtime
  • to disable the zoom you may try to use minZoom and maxZoom options (set them to the same value as zoom option), or you may try to set zoomControl to false,

  • to change the cursor which is displayed over the map use draggableCursor option, i.e. map.setOptions({ draggableCursor: 'crosshair' });. To change back to default just set it to null: map.setOptions({ draggableCursor: null });.

Upvotes: 9

Related Questions