I am listening to adding a vertex during "draw mode" as documented in docs https://github.com/geoman-io/leaflet-geoman#draw-mode
map.on('pm:drawstart', ({ workingLayer }) => {
workingLayer.on('pm:vertexadded', e => {
console.log(e);
});
});
at some point I am done drawing and "draw mode" is ended.
i then want to edit the geometry and enable "edit mode".
how can I listen to edits of the "workingLayer" in which I just draw the geometries?
I tried the following without success...
map.on('pm:drawstart', ({ workingLayer }) => {
workingLayer.on('pm:vertexadded', e => {
console.log(e);
});
workingLayer.on('pm:edit', e => {
console.log(e);
});
});
update: I then turned on my brain and came up with the following
map.on('pm:globaleditmodetoggled', e => {
e.map.pm.getGeomanDrawLayers(true).on('pm:edit', e => {
console.log(e)
});
});
is this the way to do it or does a more efficient way exist'?
Use the listener pm:create
and add to the new created layer the pm:edit
listener.
Then the event pm:edit
will be fired when a edit happens on the new layer.
map.on('pm:create', ({ layer}) => {
layer.on('pm:edit', e => {
console.log(e);
});
});