disable zooming dragging in Google maps by clicking on a button

前端 未结 2 887
别那么骄傲
别那么骄傲 2020-12-12 18:54

I want to add codes inside disable() function to disable dragging and zooming in Google maps API v3 by clicking on \'disable\' button.



        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 19:35

    You can use the setOptions() method on the map object:

    map.setOptions({draggable: false, zoomControl: false, scrollwheel: false, disableDoubleClickZoom: true});
    

    If this doesn't prevent zooming, you could always set the minimum and maximum zoom to the current zoom level.

    There is also the disableDefaultUI option, which probably takes all of these events into account, but it might disable clicking on existing elements.

提交回复
热议问题