You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GeoJsonTooltip / GeoJsonPopup crash on a single Feature or null properties #2345
GeoJson accepts a single Feature or a bare geometry as data, but adding a GeoJsonTooltip or GeoJsonPopup to such a layer crashes at render time. A feature whose properties is null, which RFC 7946 allows, crashes too.
File ".../folium/features.py", line 1216, in render
self._parent.data["features"][0]["properties"].keys()
KeyError: 'features'
With "properties": None in a FeatureCollection, the same line raises AttributeError: 'NoneType' object has no attribute 'keys'.
Expected behavior
The tooltip or popup renders, as it does when the same feature is wrapped in a FeatureCollection. For a feature with no properties, or a bare geometry, any requested field is reported with the existing "The field ... is not available" message.
Cause
GeoJson only converts data to a FeatureCollection when style_function or highlight_function is given. GeoJsonDetail.render and warn_for_geometry_collections always read data["features"], and assume the first feature's properties is a dict. TopoJson had the same kind of problem with non-collection geometries, which was fixed earlier (test_topojson_non_collection_geometry_detail).
Activity
Fix GeoJsonTooltip/GeoJsonPopup on a single Feature or null properties (