-
Notifications
You must be signed in to change notification settings - Fork 361
Fix geoman controls option update + snapping option #1247
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
Fix geoman controls option update + snapping option #1247
Conversation
mangecoeur
commented
Apr 23, 2025
- Currently, if options are changed on the GeomanDrawControl after creation, the toolbar doesn't update. This PR adds event listeners to the model attributes to remove & re-add the draw toolbar on options change so they are reflected in the UI.
- This PR also adds the snapping option to Layers, to control which layers are used by the snapping function of Geoman.
- The version of Geoman is bumped to the latest version.
…ptions to GeoJson constructor to fetch all synced values.
…safely removed without triggering an exception.
…re-adding it in case of options changing.
… for geoman controls with implementation of Control IFace within the Geoman View via addTo
…use the same options setting method as when options dynamically change.
…to .data attr for editing. Also made circlemarker style use the draw control configured style if the feature doesn't have its own style overrides.
…her way around seems to break rendering.
…ptions to GeoJson constructor to fetch all synced values.
…safely removed without triggering an exception.
…re-adding it in case of options changing.
… for geoman controls with implementation of Control IFace within the Geoman View via addTo
…use the same options setting method as when options dynamically change.
…to .data attr for editing. Also made circlemarker style use the draw control configured style if the feature doesn't have its own style overrides.
…her way around seems to break rendering.
6e9251b
to
361c8ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @mangecoeur
Just a couple of minor suggestions.
options = model.get('marker')?.markerStyle; | ||
} | ||
return new L.Marker(latlng, options); | ||
case 'circle': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case 'circle': | |
case 'circle': | |
if (!options) { | |
options = model.get('circle')?.pathOptions; | |
} |
When i was testing it, I got options undefined
everytime, so let's add a check like other cases?
this.setControlOptions(); | ||
|
||
this.map_view.obj.pm.removeControls(); | ||
if (!this.model.get('hide_controls')) { | ||
this.map_view.obj.pm.addControls(this.controlOptions); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part of code is also being repeated in setPosition()
below, maybe you want to take it out in a separate method or if you have any better idea?
By the way, if you happen to have a short clip or demo showing the improvements, that would be awesome to add here too. Thanks again! |
…e' into fix_geoman_controls_option_update
Added some examples in the GeomanDrawControls.ipnb notebook, that just shows that you can change the control settings and the toolbar updates. Below is a short clip showing the snapping that ignores all but the chosen layer. Geoman.Snap.Demo.mp4 |
Thanks @mangecoeur, this is awesome!!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!