Leaflet.Editable
Leaflet.Editable copied to clipboard
deleteShape does not work for circle
deleteShape works for every shape type except for circle.
The API suggests the use of deleteShapeAt, but it does not work on any of the shapes I've attempted to draw, and throws an exception on
var shape = this.feature.shapeAt(latlng);
, stating shapeAt is undefined.
When attempting to invoke deleteShape on circle, it fails on the following line:
this.feature.setLatLngs(this.getLatLngs());
, stating setLatLngs is not a property of feature.
I think this results from the fact that the deleteShape is generic and assumes all feature has setLatLngs, which L.circle doesn't.
Humm, thinking a bit about it, I think it's more the doc that needs to be fixed rather than the code.
Can you elaborate on your use case?
The public method deleteShape
invokes setLatLngs
on a shape.
The method setLatLngs
does not exist for certain shapes, noticeably circle, which has a single latlng.
no delete function for markers created by editable ?
@axelerate Just run into this issue today. Did find a suitable solution?
Just in case, this seems to work if you want to remove circle. I've simply modified the deleteShape function:
var deleteShape = function (e) {
if ((e.originalEvent.ctrlKey || e.originalEvent.metaKey) && this.editEnabled()) {
if (this.options.radius) {
this.remove();
} else {
this.editor.deleteShapeAt(e.latlng);
}
}
};
Instead or removing shape, it's also possible to remove object (multi polygon) by simplifying:
var deleteShape = function (e) {
if ((e.originalEvent.ctrlKey || e.originalEvent.metaKey) && this.editEnabled()) {
this.remove();
}
};