Update edit handles when the layer is updated programmatically
In my use case, layers are edited both interactively and programmatically.
When a layer is at edit mode and is updated programmatically, the edit handles are not moved accordingly. The result is like this:

A workaround is to toggle off and on the layer editing to recreate the handles:
// destroy old handles
polygon.pm.toggleEdit();
// create new handles with current coordinates
polygon.pm.toggleEdit();
It would be nice to have the handles updated automatically, since leaflet.pm has been listening to the layer changes. You can see a full demo at this plunker example.
π thanks for the demo. Good addition, I will address this!
Took a look - I asked @perliedman for help on this: https://twitter.com/TweetsOfSumit/status/1013355361573789696
I did not find a possibility to listen to changes done via leaflets setLatLngs yet π€.
The PR/Branch is here:
https://github.com/codeofsumit/leaflet.pm/pull/309
I've added the failing Cypress test for this usecase.
seems like there is no event in leaflet to catch this. I've raised a feature request with leaflet: https://github.com/Leaflet/Leaflet/issues/6214 Let's see what they say - if they include it I would like to wait for this. If not, I would try to create a workaround if there is one that is not that dirty.
In the meantime, you can use polygon.pm.enable(); instead of toggling edit mode twice.
polygon.setLatLngs([[0, 0],[0, 20],[20, 20],[20, 0]]);
polygon.pm.enable();
Calling enable again will simply update everything (you could pass new options too).
The feature request for Leaflet is this now: https://github.com/Leaflet/Leaflet/issues/2235
Created PR https://github.com/Leaflet/Leaflet/pull/7150