-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add feature_group parameter to Draw plugin #2001
Add feature_group parameter to Draw plugin #2001
Conversation
This can be used to pass existing layer objects into the Draw plugin, which the user can then edit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this change, seems really useful. I added one comment about a code block change that doesn't seem necessary.
I feel like this could benefit from an example in the user guide regarding how this option can be used. Not necessary to get this merged, but if you feel like it: https://python-visualization.github.io/folium/latest/user_guide/plugins/draw.html
folium/plugins/draw.py
Outdated
{{ this._parent.get_name() }}.on(L.Draw.Event.CREATED, function(e) { | ||
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_{{ this.get_name() }}.addLayer(layer); | ||
}); | ||
{{ this._parent.get_name() }}.on( | ||
L.Draw.Event.CREATED, | ||
function(e) { | ||
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_{{ this.get_name() }}.addLayer(layer); | ||
} | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't mix styling changes with functional changes. Seems this code didn't change functionally, so don't include it in this PR then please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.
Will add the documentation when I have a bit more time. |
This can be used to pass existing layer objects into the Draw plugin, which the user can then edit.