diff --git a/examples/simple.geo.json b/examples/simple.geo.json new file mode 100644 index 00000000..f13bdc4f --- /dev/null +++ b/examples/simple.geo.json @@ -0,0 +1,79 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "stroke": "#555555", + "stroke-width": 2, + "stroke-opacity": 1, + "fill": "#555555", + "fill-opacity": 0.5 + }, + "geometry": { + "coordinates": [ + [ + [ + 6.3198722284199675, + 46.475212657477016 + ], + [ + 5.744162894532366, + 46.10709600323992 + ], + [ + 6.497738039632395, + 45.70237717844603 + ], + [ + 7.134249175373981, + 46.14082290891099 + ], + [ + 6.448472560825223, + 46.030608286903174 + ], + [ + 6.3198722284199675, + 46.475212657477016 + ] + ] + ], + "type": "Polygon" + }, + "id": 0 + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "coordinates": [ + 6.146144956875389, + 46.4506138274553 + ], + "type": "Point" + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "coordinates": [ + [ + 5.790034254132081, + 46.35543828997646 + ], + [ + 5.693917615455717, + 46.240555677111445 + ], + [ + 5.610702086380968, + 46.37069535445781 + ] + ], + "type": "LineString" + } + } + ] +} \ No newline at end of file diff --git a/python/ipyleaflet/ipyleaflet/leaflet.py b/python/ipyleaflet/ipyleaflet/leaflet.py index 1c733503..21d607f7 100644 --- a/python/ipyleaflet/ipyleaflet/leaflet.py +++ b/python/ipyleaflet/ipyleaflet/leaflet.py @@ -660,9 +660,9 @@ class Tooltip(UILayer): offset: tuple, default (0, 0) Optional offset of the tooltip position (in pixels). direction: str, default 'auto' - Direction where to open the tooltip. - Possible values are: right, left, top, bottom, center, auto. - auto will dynamically switch between right and left according + Direction where to open the tooltip. + Possible values are: right, left, top, bottom, center, auto. + auto will dynamically switch between right and left according to the tooltip position on the map. permanent: bool, default False Whether to open the tooltip permanently or only on mouseover. @@ -2367,7 +2367,7 @@ class GeomanDrawControl(DrawControlBase): circlemarker = Dict({ 'pathOptions': {} }).tag(sync=True) # Hover style (applies for all drawing modes) - hover_style = Dict().tag(sync=True) + hover_style = Dict().tag(sync=True) # Disabled by default text = Dict().tag(sync=True) @@ -2378,6 +2378,8 @@ class GeomanDrawControl(DrawControlBase): cut = Bool(True).tag(sync=True) rotate = Bool(True).tag(sync=True) + limit_markers_to_count = Int(-1).tag(sync=True) + def __init__(self, **kwargs): super(GeomanDrawControl, self).__init__(**kwargs) self.on_msg(self._handle_leaflet_event) @@ -2420,7 +2422,7 @@ def on_click(self, callback, remove=False): Whether to remove this callback or not. Defaults to False. """ self._click_callbacks.register_callback(callback, remove=remove) - + def clear_text(self): """Clear all text.""" diff --git a/python/jupyter_leaflet/src/controls/GeomanDrawControl.ts b/python/jupyter_leaflet/src/controls/GeomanDrawControl.ts index 5c39f415..976f6996 100644 --- a/python/jupyter_leaflet/src/controls/GeomanDrawControl.ts +++ b/python/jupyter_leaflet/src/controls/GeomanDrawControl.ts @@ -136,6 +136,8 @@ export class LeafletGeomanDrawControlView extends LeafletControlView { this.data_to_layers(); this.map_view.obj.addLayer(this.feature_group); + this.setControlOptions(); + this.setMode(); this.map_view.obj.on( @@ -398,7 +400,13 @@ export class LeafletGeomanDrawControlView extends LeafletControlView { mode = mode.split(':')[1]; this.map_view.obj.pm.enableDraw(mode, this.model.get(mode.toLowerCase())); } else if (mode == 'edit') { - this.map_view.obj.pm.enableGlobalEditMode(); + let n_markers = this.model.get('limit_markers_to_count'); + if (!n_markers) { + n_markers = -1; + } + this.map_view.obj.pm.enableGlobalEditMode({ + limitMarkersToCount: n_markers + }); } else if (mode == 'drag') { this.map_view.obj.pm.enableGlobalDragMode(); } else if (mode == 'remove') {