-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Event handling of plugins #328
Comments
I've managed to add For reference, here is how the demo page at https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/ does it: In my app, here's how it turned out: Both GIF's few seconds involve me clicking in and outside of the polygon feature: there is flickering because I've taken a look at the event object that was being returned in an Is there a way to include the |
@ralphstodomingo Unfortunately we have to disable the native event handling of mapbox-gl, because the native interaction events are only fired after the map updates and therefore break the synchronization between the map and its overlays. @abmai This topic has come up multiple times and we have written components like this for internal projects. Maybe we should add an example to share that code? |
@Pessimistress Is it right to assume that the way to move forward with this particular plugin would be to write a child component? Without using |
Just speculating - you may be able to hack |
@Pessimistress Can you give me pointers on how to achieve a similar implementation? I've been hacking at it from the |
I've made an attempt at it here: https://github.com/maphubs/mapbox-gl-draw Had to hack mapbox-gl-draw to wire it to the react-map-gl eventManager, convert the wrapped events to match what is used internally in mapbox-gl-js, disable dragPan when needed, and update the cursors. It is also needed to overlay the controls outside of the InteractiveMap component, otherwise they cause selected features to unselect, related to #304 This unfortunately is still an issue with the react-map-gl navigation control, zooming the map fires a click clearing the selection. |
also hope to use mapbox-gl-draw, or other similar implementation in react-map-gl/deck.gl. but find it really difficult. |
I would also love to know, @Pessimistress, how y'all handle this internally if possible? Or what other people have come up with in solving this feature. |
@akiori I didn't end up using that mapbox-gl-draw fork, decided to keep my own React wrappers around mapbox-gl because I didn't really need the deck.gl overlays. I do remember getting my measurement tools to work using that fork, the best I can do is point you to this commit in the branch where I was testing it, maybe it will show a bit more of how I wired it up. maphubs/maphubs@94f50a0 I'm getting the react-map-gl instance via a ref, and passing it down into my measurement tool component and then to the mapbox-gl-draw instance (from my fork) so it can rewire itself to react-map-gl's event manager... bit of a hack. |
This prop controls if map style should be updated on changes. Also whilst this is true panning is disabled. You might set this to false whilst integrating with mapbox-gl-draw. The work is based off of the following issues: - visgl#725 - @ibgreen pointed out that this sort of prop would make for an easy integration. - visgl#450 - visgl#328
Closing for inactivity. The latest recommendation is to use react-map-gl-draw: http://visgl.github.io/react-map-gl/examples/draw-polygon |
How would a plugin e.g.
mapbox-gl-draw
be integrated into react-map-gl? I tried using themapControls
attribute inInteractiveMap
but I got an error that simply meant it did not match the interfacemapControls
was expecting.I'm also not sure how the construction of the
Popup
andMarker
controls work. How do they manage to keep track of the map coordinates?The text was updated successfully, but these errors were encountered: