Relative Content

Tag Archive for shinyr-leafletr-mapedit

R shiny leafpm: Polygon duplicated when using ‘Cut layers’

I’m building a Shiny app using leafpm polygon editor. Basically I apply some changes to an existing polygon, then I save the edited polygons and edit the leaflet map by removing polygons and adding the new polygons.
My problem is that I don’t manage to make the function removeShape() work for “Cut layers” leafpm option. You can see in the reprex below that if you edit the polygon shape with the “Edit layers” tool, when you click on save the polygon is removed and replaced well (I changed the colour so that it’s easy to see that the polygon was replaced). If you edit the polygon shape with the “Cut layers” tool and click on save, removeShape() does not work and you end up with two duplicate polygons overlapping (one with the original colour and one with the new colour; you can use the “Drag layers” tool to visualise it).