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

Observe & update draw options #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Techn1x
Copy link

@Techn1x Techn1x commented Jan 15, 2018

This PR branches off of the 'initial-features' PR I also made here #9

I needed a way to change the options for new shapes that are drawn (specifically, I needed to change the colour). This is a first attempt at getting the 'draw' arg to be observed so that new shapeOptions can be applied, using the leaflet-draw method setDrawingOptions. Seems to work, I have only tested changing the colour though.

I also included a commented out section in _drawChanged() which will also apply the new draw shapeOptions to existing objects that were previously drawn. There are some caveats to that code;

  • Not sure how to tell what shape a previously drawn object is (they're all instances of L.Polygon..), so it just gets the draw.initial.shapeOptions applied to it, this is probably not desired
  • Users may not want existing shapes to be updated with new draw options - perhaps existing shapes should be updated in some other way? Or put this functionality behind an arg to the component called something like updateExistingShapes=true ?

My leaflet skills aren't the best and I've only been using this addon for a day so please chime in if you know any improvements that can be made (or just go ahead and commit them!)

@Techn1x
Copy link
Author

Techn1x commented Jan 16, 2018

Might be a better way to do this using ember-diff-attrs and didUpdateAttrs(), rather than observers
https://github.com/workmanw/ember-diff-attrs

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

Successfully merging this pull request may close these issues.

1 participant