@@ -17,6 +17,8 @@ class Draw(JSCSSMixin, MacroElement):
1717 position : {'topleft', 'toprigth', 'bottomleft', 'bottomright'}
1818 Position of control.
1919 See https://leafletjs.com/reference.html#control
20+ show_geometry_on_click : bool, default True
21+ When True, opens an alert with the geometry description on click.
2022 draw_options : dict, optional
2123 The options used to configure the draw toolbar. See
2224 http://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#drawoptions
@@ -60,10 +62,12 @@ class Draw(JSCSSMixin, MacroElement):
6062 var layer = e.layer,
6163 type = e.layerType;
6264 var coords = JSON.stringify(layer.toGeoJSON());
65+ {%- if this.show_geometry_on_click %}
6366 layer.on('click', function() {
6467 alert(coords);
6568 console.log(coords);
6669 });
70+ {%- endif %}
6771 drawnItems.addLayer(layer);
6872 });
6973 {{ this._parent.get_name() }}.on('draw:created', function(e) {
@@ -104,6 +108,7 @@ def __init__(
104108 export = False ,
105109 filename = "data.geojson" ,
106110 position = "topleft" ,
111+ show_geometry_on_click = True ,
107112 draw_options = None ,
108113 edit_options = None ,
109114 ):
@@ -112,6 +117,7 @@ def __init__(
112117 self .export = export
113118 self .filename = filename
114119 self .position = position
120+ self .show_geometry_on_click = show_geometry_on_click
115121 self .draw_options = draw_options or {}
116122 self .edit_options = edit_options or {}
117123
0 commit comments