Skip to content
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

Update VectorGridProtobuf to include popups when clicked #1933

Closed
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
14 changes: 14 additions & 0 deletions folium/plugins/vectorgrid_protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ class VectorGridProtobuf(JSCSSMixin, Layer):
{{ this.options if this.options is string else this.options|tojson }}
{%- endif %}
);
// Attach popup event
{{ this.get_name() }}.on('click', function (e) {
const properties = e.layer.properties;
var popupContent = "";
for (var property in properties) {
if (properties.hasOwnProperty(property)) {
popupContent += "<b>" + property + ":</b> " + properties[property] + "<br>";
}
}
L.popup()
.setContent(popupContent)
.setLatLng(e.latlng)
.openOn(map);
});
{%- endmacro %}
"""
)
Expand Down