Closed EXio4 closed 2 years ago
Yes but here is the problem, that we don't get a information from leaflet when the style is changed, so we can't implement anything that listen on that and automatically change the "map state".
A workaround is to call toggleGlobalEditMode()
twice:
const switchPm = (poly) => {
console.log(poly)
poly.setStyle({ pmIgnore: !poly.options.pmIgnore })
L.PM.reInitLayer(poly)
map.pm.toggleGlobalEditMode() // disable mode
map.pm.toggleGlobalEditMode() // renable mode
}
If you dynamically change pmIgnore using the method provided by https://github.com/geoman-io/leaflet-geoman#getting-started - things like edit/drag mode/anything relying on findLayers aren't properly tracked, so you are left with a situation where the "state" of the map isn't exactly representative of what the functions meant (or intuitively represent)
A way to trigger the issue is to:
JSFiddle showing the issue: https://jsfiddle.net/exio4/7qba46ch/