Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hold shift to draw rectangle and zoom into it on the map. #775

Closed
baxter1707 opened this issue Apr 18, 2019 · 6 comments
Closed

Hold shift to draw rectangle and zoom into it on the map. #775

baxter1707 opened this issue Apr 18, 2019 · 6 comments

Comments

@baxter1707
Copy link

Hey! Great work on the library! I was wondering what it would take to be able to hold shift down and then draw a rectangle and then zoom to that point.

Mapbox GL had something like that built in and the following code can be found at the link below.
https://github.com/mapbox/mapbox-gl-js/blob/e9559550ca9b35eb0e8b509e110e8db7f961fd85/src/ui/handler/box_zoom.js

This is from there example, and what I am hoping to accomplish.
HoldingShift

Thank you guys again for any feedback and the work you have done!

@arnaskro
Copy link

Hey @baxter1707, I wanted to enable this option in my project as well, but haven't found a way to do that yet. Clearly the option is there and the Mapbox GL documentation says that we can do that.

If I call getMap on the map node I can see that boxZoom option is there. I tried calling map.boxZoom.enable() but no luck...

I ended up finding this issue and was wondering if you got the boxZoom option working for you somehow or not?

@brendan33
Copy link

Also looking for a way to implement this.
I guess react-map-gl overwrites the standard mapbox-gl handlers, but seems that the new SHIFT functionality is the same as CTRL so not quite sure why its been replaced.

@louisroy
Copy link

Also looking for a way to do this. As a reference, alex3165/react-mapbox-gl, which is a similar library, doesn't currently have this problem (box zoom is enabled by default).

@garretteklof
Copy link

garretteklof commented Feb 14, 2021

@Pessimistress would you be able to provide any insight on the best way to accomplish this? My first thought was to extend the controller, however, can't really replicate the box zoom functionality (without attempting to rewrite it in the controller itself). Like the comments above, I see boxZoom on the mapbox instance but enabling does nothing (active flag is set to false). Maybe a trivial thing I'm simply overlooking. Any guidance is very much appreciated 😅

edit: also, I disabled dragRotate to override SHIFT key default

@Pessimistress
Copy link
Collaborator

This can be done by extending the controller class. I do not have the bandwidth to get to this at the moment, any PR would be greatly appreciated.

@Pessimistress
Copy link
Collaborator

This is being addressed in v7.0. Please follow #1646

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants