Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is there no layer.deleting #328

Open
schmijos opened this issue Sep 25, 2014 · 3 comments
Open

Why is there no layer.deleting #328

schmijos opened this issue Sep 25, 2014 · 3 comments

Comments

@schmijos
Copy link

We can ask a layer if it is being dragged or edited by calling layer.editing.enabled(). Why don't we have this for deletion?

@justinmanley
Copy link
Member

Calling layer.editing.enabled() will tell you if editing mode is enabled for a layer.

While in editing mode, it is possible for users to alter a layer (for example, by dragging edit handles), or to delete a layer.

Calling 'layer.editing.enabled() will not tell you if a layer has been edited.

If you want to find out whether a layer has been edited before it is saved, you can check the value of layer.edited (see L.EditToolbar.Edit#save, line 95). Keep in mind that this is not a documented property, so you might not want to rely on it.

There's not a corresponding layer.deleted property for layers which have been deleted, but not yet saved. Instead, you can check whether a layer has been added to the _deletedLayers LayerGroup if you want to find out whether a layer has been deleted before it is saved.

If you can wait until the layers are saved, then you can listen for the draw:deleted event (same goes for the draw:edited event).

@schmijos
Copy link
Author

schmijos commented Oct 1, 2014

Ok, thank you very much. The _deletedLayers group was what I searched for. Nevertheless it would be good to be consistent with modes. There should be a mode for every concept regarding start and stop events (like we have it for editing).

@jacobtoye
Copy link
Member

The method that @manleyjster describes will work fine. The references commits add events that you can listen to. I've also added reverted events for when the user clicks the cancel button.

Unfortunately you cannot listen to these events on the L.Feature Group. 0.8-dev Leaflet adds better support for propagating events. I will need to add support for using this when I do more work for Leaflet.Draw and Leaflet 0.8.

You will need to do a fresh build to get the latest changes. Sorry I haven't fully tested this, baby has just woken up ;) It looks good to go though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants