Draw Events
Closed this issue · 4 comments
rcbyrne commented
Hello,
How can I attach event listeners?
Thanks
erick-otenyo commented
I did a fork that implements the draw events as props here . Let me know if it helps or any improvements.. thanks
amaury1093 commented
Hi @rcbyrne. As stated in the react-mapbox-gl docs, you can get access to the map
object in onStyleLoad
.
Once you have the map
object, a simple
map.on('draw.create', function (e) {
console.log(e.features);
});
would do the trick.
Here's the full code:
<Map
// ...other props
onStyleLoad={map => {
map.on('draw.create', e => {
console.log(e.features);
});
}}
/>
Another method proposed by @erick-otenyo with props, see ongoing PR #5.
amaury1093 commented
Fixed by #5.
erick-otenyo commented
Awesome