From ee298f650ca392e26243dc535d301d92eb228eb6 Mon Sep 17 00:00:00 2001 From: Iisakki Rotko Date: Mon, 22 Apr 2024 12:06:38 +0200 Subject: [PATCH] fix: correct default options previously `circlemarker` incorrectly defaulted to using `markerStyle`, while it isn't a leaflet marker layer. Moreover, polyline and polygon would use the old (`shapeOptions`) by default even with geoman, where it should be `pathOptions`. This was fixed by the compatibility layer, but this way the defaults are clearer. --- python/ipyleaflet_core/ipyleaflet/leaflet.py | 21 ++++++++++++------- .../src/controls/GeomanDrawControl.ts | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/python/ipyleaflet_core/ipyleaflet/leaflet.py b/python/ipyleaflet_core/ipyleaflet/leaflet.py index 520ece47..52a3be7e 100644 --- a/python/ipyleaflet_core/ipyleaflet/leaflet.py +++ b/python/ipyleaflet_core/ipyleaflet/leaflet.py @@ -2129,11 +2129,6 @@ def _handle_leaflet_event(self, _, content, buffers): class DrawControlBase(Control): - # Different drawing modes - # See https://www.geoman.io/docs/modes/draw-mode - polyline = Dict({ 'shapeOptions': {} }).tag(sync=True) - polygon = Dict({ 'shapeOptions': {} }).tag(sync=True) - # Leave empty to disable these circle = Dict().tag(sync=True) rectangle = Dict().tag(sync=True) @@ -2205,7 +2200,9 @@ class DrawControl(DrawControlBase): # You can add Leaflet style options in the shapeOptions sub-dict # See https://github.com/Leaflet/Leaflet.draw#polylineoptions and # https://github.com/Leaflet/Leaflet.draw#polygonoptions - circlemarker = Dict({'shapeOptions': {}}).tag(sync=True) + polyline = Dict({ 'shapeOptions': {} }).tag(sync=True) + polygon = Dict({ 'shapeOptions': {} }).tag(sync=True) + circlemarker = Dict({ 'shapeOptions': {} }).tag(sync=True) last_draw = Dict({"type": "Feature", "geometry": None}) last_action = Unicode() @@ -2239,7 +2236,11 @@ class GeomanDrawControl(DrawControlBase): # Hides toolbar hide_controls = Bool(False).tag(sync=True) - circlemarker = Dict({'pathOptions':{}}).tag(sync=True) + # Different drawing modes + # See https://www.geoman.io/docs/modes/draw-mode + polyline = Dict({ 'pathOptions': {} }).tag(sync=True) + polygon = Dict({ 'pathOptions': {} }).tag(sync=True) + circlemarker = Dict({ 'pathOptions': {} }).tag(sync=True) # Disabled by default text = Dict().tag(sync=True) @@ -2293,7 +2294,11 @@ class DrawControlCompatibility(DrawControlBase): _view_name = Unicode("LeafletGeomanDrawControlView").tag(sync=True) _model_name = Unicode("LeafletGeomanDrawControlModel").tag(sync=True) - circlemarker = Dict({'shapeOptions': {}}).tag(sync=True) + # Different drawing modes + # See https://www.geoman.io/docs/modes/draw-mode + polyline = Dict({ 'shapeOptions': {} }).tag(sync=True) + polygon = Dict({ 'shapeOptions': {} }).tag(sync=True) + circlemarker = Dict({ 'shapeOptions': {} }).tag(sync=True) last_draw = Dict({ 'type': 'Feature', diff --git a/python/jupyter_leaflet/src/controls/GeomanDrawControl.ts b/python/jupyter_leaflet/src/controls/GeomanDrawControl.ts index 24e9f65d..bc9ad35a 100644 --- a/python/jupyter_leaflet/src/controls/GeomanDrawControl.ts +++ b/python/jupyter_leaflet/src/controls/GeomanDrawControl.ts @@ -17,7 +17,7 @@ export class LeafletGeomanDrawControlModel extends LeafletControlModel { hide_controls: false, data: [], marker: {}, - circlemarker: { markerStyle: {} }, + circlemarker: { pathOptions: {} }, circle: {}, polyline: { pathOptions: {} }, rectangle: {},