This is very nice feature that I was looking to implement but since I am using rmarkdown and leaflet package I am having tremendous difficulties to make this work within RStudio and leaflet package. I am not sure if you or leaflet package maintainers could help me solve this issue? I would like to use the zoom box in this map: https://emdelponte.github.io/FGSC-database/
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 pressedif(e.code==='ShiftLeft'||e.code==='ShiftRight'){self.map.boxZoom.setStateOff();}});document.addEventListener('keyup',function(e){// Disable box zoom while shift is pressedif(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?
Any chance of changing the pointer to something else, for example a '+' or something when box zoom button is clicked? The default (hand) pointer is kinda confusing to end users. Otherwise a great plugin π
Hi,
First, thanks for your plugin, itβs very useful.
But I have one question; do you think itβs possible to do a zoom out by box?
Do you have some ideas?
Thanks.
Thanks for a great plugin. Just letting you know the keepOn option does not work. When set to true in the control it does not change the behaviour from default behaviour.
ctlZoomBox = L.Control.boxzoom({ position:'bottomright', keepOn:true}).addTo(map);
Leaflet uses "cursor: pointer" in the class .leaflet-interactive on svg path elements. This overrides the "cursor: crosshair !important" for .leaflet-container.leaflet-control-boxzoom-active. This means that when trying to create a box zoom over svg path elements the cursor will flip back and forth between crosshair and pointer.
Adding an additional selector for .leaflet-interactive for the path element worked around the issue for us. Not sure if there's a better way though.