Skip to content

While boxzoom is active, allow Shift+Drag to pan #14

@techdaddies-kevin

Description

@techdaddies-kevin

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions