Fix geoman controls option update + snapping option#1247
Fix geoman controls option update + snapping option#1247martinRenou merged 32 commits intojupyter-widgets:masterfrom
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
arjxn-py
left a comment
There was a problem hiding this comment.
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.
| 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.
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!!! |