Draw: add show_geometry_on_click parameter
@@ -17,6 +17,8 @@ class Draw(JSCSSMixin, MacroElement):
position : {'topleft', 'toprigth', 'bottomleft', 'bottomright'}
Position of control.
See https://leafletjs.com/reference.html#control
+ show_geometry_on_click : bool, default True
+ When True, opens an alert with the geometry description on click.
draw_options : dict, optional
The options used to configure the draw toolbar. See
http://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#drawoptions
@@ -60,10 +62,12 @@ class Draw(JSCSSMixin, MacroElement):
var layer = e.layer,
type = e.layerType;
var coords = JSON.stringify(layer.toGeoJSON());
+ {%- if this.show_geometry_on_click %}
layer.on('click', function() {
alert(coords);
console.log(coords);
});
+ {%- endif %}
drawnItems.addLayer(layer);
});
{{ this._parent.get_name() }}.on('draw:created', function(e) {
@@ -104,6 +108,7 @@ class Draw(JSCSSMixin, MacroElement):
export=False,
filename="data.geojson",
position="topleft",
+ show_geometry_on_click=True,
draw_options=None,
edit_options=None,
):
@@ -112,6 +117,7 @@ class Draw(JSCSSMixin, MacroElement):
self.export = export
self.filename = filename
self.position = position
+ self.show_geometry_on_click = show_geometry_on_click
self.draw_options = draw_options or {}
self.edit_options = edit_options or {}
