Leaflet / Leaflet.draw

Vector drawing and editing plugin for Leaflet
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html
MIT License
1.98k stars 994 forks source link

draw:canceled event not included in Leaflet.Draw.Event.js #1010

Open darrenklein opened 3 years ago

darrenklein commented 3 years ago

I've skipped the template because I'm not reporting a bug, exactly, just a (hopefully) helpful tip. I needed specific behavior when a user canceled drawing via clicking the "Escape" key, which triggers the "draw:canceled" event. I expected to find that event listed among the events in https://github.com/Leaflet/Leaflet.draw/blob/develop/src/Leaflet.Draw.Event.js, however it wasn't included there. That module is really helpful, and I used a few other events there for other purposes (such as L.Draw.Event.DRAWSTOP, but there is no L.Draw.Event.DRAWCANCELED... so if you need to listen for the canceled event, try this:

map.mapObject.on("draw:canceled", (event) => {
        console.log(event);
});

I'd open a PR to add that event to the https://github.com/Leaflet/Leaflet.draw/blob/develop/src/Leaflet.Draw.Event.js, but it appears that this repo is no longer being maintained.

manandkumaar commented 2 years ago

Team, Do we have any plan to add canceled event part of draw lib itself?. I came across this issue today and provided a fix in the app to handle it.

ma7moudat commented 1 year ago

I also need to handle draw:canceled. Could we add this, please?