Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions folium/plugins/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -104,6 +108,7 @@ def __init__(
export=False,
filename="data.geojson",
position="topleft",
show_geometry_on_click=True,
draw_options=None,
edit_options=None,
):
Expand All @@ -112,6 +117,7 @@ def __init__(
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 {}

Expand Down