Disable the Ctrl + Scroll to Zoom google maps

后端 未结 5 1606
野性不改
野性不改 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:27

    I wasn't able to get the gestureHandling: 'greedy' fix to work for me since I had an overlay over the map. I ended up detecting the mousewheel event and setting the ctrl property to true.

    // Load maps and attach event listener to scroll event.
    var $map = $('.map');
    $map[0].addEventListener('wheel', wheelEvent, true);         
    
    function wheelEvent(event) {
        // Set the ctrlKey property to true to avoid having to press ctrl to zoom in/out.
        Object.defineProperty(event, 'ctrlKey', { value: true });
    }
    

提交回复
热议问题