-
Notifications
You must be signed in to change notification settings - Fork 992
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
Enable marker editing #323
Conversation
… layer is a marker.
…is enabled correctly.
Just added two new tests in |
@jacobtoye @danzel any thoughts on this? |
Please remove your changes from the I don't know if it is possible, but could we remove the remaining type checking too? (the |
Awesome pull @manleyjster! Sorry I haven't gotten onto this earlier. Like @danzel says could you please back out the changes to the |
…rs: Remove 'isMarker' tests from L.EditToolbar.Edit and set layer styles for editing mode in L.Edit.Poly and L.Edit.SimpleShape, rather than L.EditToolbar.Edit.
…en editing mode is enabled and disabled.
I've removed the remaining type checking for This involved tweaking how styles for editing mode are set. The I've added two more tests to PR should be ready for merge. |
L.EditToolbar.Edit decides how to handle layers based on the layer type. The process goes like this:
layer instanceof L.Marker
istrue
, then L.EditToolbar.Edit does a series of marker-specific editing actions.L.EditToolbar.Edit
does a few style tweaks, then callslayer.editing.enable()
, delegating the specific editing behavior to the handler for that layer (i.e.L.Edit.Rectangle
,L.Edit.Circle
,L.Edit.Polyline
, etc.). This means thatlayer.editing.enable()
is not called iflayer
inherits fromL.Marker
.This was a problem for me because I have a complex layer,
L.Illustrate.Textbox
, which inherits fromL.Marker
, but needs to have custom editing behavior.As I looked at the code for
L.EditToolbar.Edit
, it seemed that the differential handling of layers into based on marker / non-marker type was fairly arbitrary. Furthermore, there were two lengthy marker-specific methods -_toggleMarkerHighlight
and_offsetMarker
- inL.EditToolbar.Edit
that didn't seem to belong to a general-purpose editing class.I have refactored
L.EditToolbar.Edit
to address these issues, moving marker-specific behavior into a newL.Edit.Marker
class. This is nice because it makeslayer.editing.enable()
a universal method for turning on editing behavior, regardless of the layer type. As a bonus, it also makes it easy for plugin developers to override the default editing behavior for classes extendingL.Marker
.