Disable the Ctrl + Scroll to Zoom google maps

后端 未结 5 1609
野性不改
野性不改 2021-01-30 07:59

Does anybody know how to disable the CTRL + Scroll?

First when the mouse wheel was moved the Map would Zoom in/out. But now it asks to press

5条回答
  •  耶瑟儿~
    2021-01-30 08:28

    You need to pass gestureHandling: 'greedy' to your map options.

    Documentation: https://developers.google.com/maps/documentation/javascript/interaction#gestureHandling

    For example:

    const map = new google.maps.Map(mapElement, {
      center: { 0, 0 },
      zoom: 4,
      gestureHandling: 'greedy'
    });
    

    Update! Since Google Maps 3.35.6 you need to encase the property into an options wrapper:

    const map = new google.maps.Map(mapElement, {
      center: { 0, 0 },
      zoom: 4,
      options: {
        gestureHandling: 'greedy'
      }
    });
    

    Thank you ealfonso for the new info

提交回复
热议问题