L.Control.BoxZoom icon indicating copy to clipboard operation
L.Control.BoxZoom copied to clipboard

While boxzoom is active, allow Shift+Drag to pan

Open techdaddies-kevin opened this issue 4 years ago • 1 comments

We're using this package (Great work, BTW) to keep boxzoom activated on a map so that the users can drag a box to search for markers in an area. This works great. What we now want to do is allow the user to hold Shift while dragging to activate pan mode in Leaflet. I thought this would be easy by doing this:

document.addEventListener('keydown', function(e) {
    // Disable box zoom while shift is pressed
    if(e.code === 'ShiftLeft' || e.code === 'ShiftRight') {
        self.map.boxZoom.setStateOff();
    }
});
document.addEventListener('keyup', function(e) {
    // Disable box zoom while shift is pressed
    if(e.code === 'ShiftLeft' || e.code === 'ShiftRight') {
        self.map.boxZoom.setStateOn();
    }
});

This does successfully disable boxzoom while shift is pressed, and does activate the cursor pointer, but dragging doesn't actually do anything. It doesn't boxzoom AND it doesn't pan. What am I doing wrong here?

Thanks in advance!

techdaddies-kevin avatar Oct 25 '21 19:10 techdaddies-kevin

And what in mobile?

valerio-bozzolan avatar Feb 15 '22 08:02 valerio-bozzolan