My purpose here is to allow only one polygon on the map. My approach has been saving the new layer during onCreated
method in a var or array and in the method onDrawStart
get it and delete, so once the user tries to draw another shape, the previous one gets removed, but this is not working, any suggestion how to make it possible?
onCreated = (e) => {
coordinates = e.layer._bounds;
layer.push(e.layer);
}
onDrawStart = (e) => {
layer.forEach((ele) => {
ele.remove()
});
}
Is there maybe any way to access to onDelete and to access here to the built in remove all??