Uh oh!
There was an error while loading. Please reload this page.
Issue 1520: Propagate feature to child layers of multi-geometries - #2263
Conversation
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. Fixespython-visualization#1520
A GeometryCollection containing a MultiPoint produces a FeatureGroup inside a FeatureGroup, placing the hovered marker two levels below the layer that owns `feature`. eachLayer only iterates one level, so the propagation now recurses.
hansthen
commented
Aug 8, 2026
@nina-mir This looks like a promising and elegant approach. I must admit I do not grasp quite how this change solves the issue. Could you explain this a bit more (just for my curiosity)? Interested to see the regression tests. I'd be happy to accept this here. Isn't this also an upstream problem? It looks like an issue in Leaflet itself as well. |
Happy to explain! The chain begins with the The catch is what
So the two ends disagree: The patch copies the feature down onto the children inside It also explains why On upstream: I tested it outside folium via plain Leaflet from a CDN, the reporter's coordinates, tooltip content as a function reading I couldn't find an existing Leaflet issue for this. Happy to open one with the repro if you think it's worth raising — though with 1.x in maintenance and 2.x behaving the same, handling it here seems worthwhile either way. Glad to share the test pages too. |
nina-mir
commented
Aug 9, 2026
Test added. It fails on Two notes on how it's written:
|
hansthen
commented
Aug 16, 2026
I will have a look at it tomorrow. Sorry for the delay in responding. I have had guests over and not much time for life online. |
nina-mir
commented
Aug 17, 2026
thank you! no rush on my part. I wish you a wonderful week! :-) |
Uh oh!
There was an error while loading. Please reload this page.
hansthen
commented
Aug 25, 2026
Hi @nina-mir I merged the PR but there is still an issue of the failing Selenium tests. Do you think these will be solved by the version bump you mentioned? Are you willing to create a separate PR for that? |
nina-mir
commented
Aug 25, 2026
Hi @hansthen, Thank you! Yes, the error will go away with the version bump. I am on it. Will do the PR right away! |
Leaflet's
geometryToLayerreturns aFeatureGroupforMultiPoint, andaddDataassignsfeatureto that group only. Tooltips resolve their source to the layer that fired the event, which is a child marker with nofeature, so the content function throws before rendering. This copies the feature onto child layers inonEachFeature, descending recursively so that nested groups — aGeometryCollectioncontaining aMultiPoint— are also covered.Verified in Firefox/Chrome against the reporter's snippet and a matrix of all eight geometry types.
MultiLineStringandMultiPolygonare unaffected, since Leaflet flattens those into a single layer rather than a group.FeatureGroupFeatureGroupGeometryCollectioncontainingMultiPointFeatureGroupConsole error before the fix
If this approach looks right, the
MultiPointlimitation in the GeoJSON docs and theGeometryCollectionwarning inGeoJsonDetailwould need updating. Happy to do that here or in a follow-up.Tested with
0.20.0(reproduction) and this branch off03cb432folium/folium.pyTwo tests fail on this branch, both of which also fail on clean
main:tests/test_map.py::test_icon_invalid_marker_colors—Icon.__init__callscolor.startswith("#")before validating the type, socolor=42raisesAttributeErrorinstead of emitting the expectedUserWarning(folium/map.py:436). Unrelated to this change; happy to open a separate issue or PR.tests/plugins/test_time_slider_choropleth.py::test_timedynamic_geo_json—geodatasetsnot installed locally.tests/test_features.py: 20 passed.tests/test_map.pyandtests/plugins: 91 passed, 2 failed (both above).Fixes#1520