Skip to content

Commit

Permalink
fix: correct default options
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
iisakkirotko committed Apr 22, 2024
1 parent 0c730e0 commit ee298f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions python/ipyleaflet_core/ipyleaflet/leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion python/jupyter_leaflet/src/controls/GeomanDrawControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class LeafletGeomanDrawControlModel extends LeafletControlModel {
hide_controls: false,
data: [],
marker: {},
circlemarker: { markerStyle: {} },
circlemarker: { pathOptions: {} },
circle: {},
polyline: { pathOptions: {} },
rectangle: {},
Expand Down

0 comments on commit ee298f6

Please sign in to comment.