Skip to content

Commit 7f7343d

Browse files
Make Leaflet-Geoman ignore created layers by default (#1220)
* Make Leaflet-Geoman ignore created layers by default, fixes #1215 * Fix existing Geoman documentation list, not rendered as such * Document `pm_ignore=False` in Geoman Draw Control documentation page * Use circle and disable circlemarker in GeomanDrawControl example * This is more sensible and aligned with the other examples.
1 parent 3551b13 commit 7f7343d

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

docs/controls/geoman_draw_control.rst

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Geoman Draw Control
2-
============
2+
===================
33

4-
``GeomanDrawControl`` allows one to draw various shapes on the map.
4+
``GeomanDrawControl`` allows one to draw various shapes on the map.
55
The drawing functionality on the front-end is provided by `geoman <https://geoman.io/>`_.
66

77
The following shapes are supported:
8+
89
- marker
910
- circlemarker
1011
- circle
@@ -24,11 +25,14 @@ Additionally, there are modes that allow editing of previously drawn shapes:
2425
To have a drawing tool active on the map, pass it a non-empty dictionary with the desired options, see
2526
`geoman documentation <https://www.geoman.io/docs/modes/draw-mode#customize-style>`_ for details.
2627

28+
By default, editing is disabled for shapes created programmatically as described in the :ref:`layers-section` page.
29+
However, adding ``pm_ignore=False`` to shapes allows them to be modified using the control.
30+
2731
Example
2832
-------
2933
.. jupyter-execute::
3034

31-
from ipyleaflet import Map, GeomanDrawControl
35+
from ipyleaflet import Map, GeomanDrawControl, Circle
3236

3337
m = Map(center=(50, 354), zoom=5)
3438

@@ -47,13 +51,14 @@ Example
4751
"fillOpacity": 1.0
4852
}
4953
}
50-
draw_control.circlemarker = {
54+
draw_control.circle = {
5155
"pathOptions": {
5256
"fillColor": "#efed69",
5357
"color": "#efed69",
5458
"fillOpacity": 0.62
5559
}
5660
}
61+
draw_control.circlemarker = {}
5762
draw_control.rectangle = {
5863
"pathOptions": {
5964
"fillColor": "#fca45d",
@@ -64,6 +69,12 @@ Example
6469

6570
m.add(draw_control)
6671

72+
circle = Circle(location=(50, 352), radius=100000, color="blue")
73+
m.add(circle)
74+
75+
editable_circle = Circle(location=(50, 356), radius=100000, pm_ignore=False, color="red")
76+
m.add(editable_circle)
77+
6778
m
6879

6980
Methods

docs/layers/index.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _layers-section:
2+
13
Layers
24
======
35

python/ipyleaflet/ipyleaflet/leaflet.py

+4
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ class Layer(Widget, InteractMixin):
171171
Interactive widget that will be shown in a Popup when clicking on the layer.
172172
pane: string
173173
Name of the pane to use for the layer.
174+
pm_ignore: boolean
175+
Make Leaflet-Geoman ignore the layer, so it cannot modify it.
174176
"""
175177

176178
_view_name = Unicode("LeafletLayerView").tag(sync=True)
@@ -195,6 +197,8 @@ class Layer(Widget, InteractMixin):
195197
options = List(trait=Unicode()).tag(sync=True)
196198
subitems = Tuple().tag(trait=Instance(Widget), sync=True, **widget_serialization)
197199

200+
pm_ignore = Bool(True).tag(sync=True, o=True)
201+
198202
@validate("subitems")
199203
def _validate_subitems(self, proposal):
200204
"""Validate subitems list.

0 commit comments

Comments
 (0)