Skip to content

Commit 157d46a

Browse files
committed
Propagate feature to child layers of multi-geometries
Leaflet's geometryToLayer returns a FeatureGroup for MultiPoint, and addData assigns `feature` to that group only. Tooltips resolve their source to the layer that fired the event (Tooltip.js:418, v1.9.3), which is a child marker with no `feature`, so GeoJsonTooltip and GeoJsonPopup throw and never render. Copy the feature onto child layers in onEachFeature, before any user-supplied callback, so both see the same data. Fixes #1520
1 parent 03cb432 commit 157d46a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

folium/features.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,11 @@ class GeoJson(Layer):
586586
{%- endif %}
587587
588588
function {{this.get_name()}}_onEachFeature(feature, layer) {
589+
if (typeof layer.eachLayer === "function") {
590+
layer.eachLayer(function (child) {
591+
if (child.feature === undefined) { child.feature = feature; }
592+
});
593+
}
589594
{%- if this.on_each_feature %}
590595
({{this.on_each_feature}})(feature, layer);
591596
{%- endif %}

0 commit comments

Comments
 (0)