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

Geojsonpopup change when cell is empty #1989

Open
jrjdavidson opened this issue Aug 27, 2024 · 1 comment
Open

Geojsonpopup change when cell is empty #1989

jrjdavidson opened this issue Aug 27, 2024 · 1 comment
Labels
bug An issue describing unexpected or malicious behaviour

Comments

@jrjdavidson
Copy link

Describe the bug
Very small bug, but there has been a small change in how empty values are handled and updating to the latest folium has affected how popups are displayed.
When creating a geojsonpopup using the fields keywords and a geodataframe, if a cell was empty the the content used to be empty. This allowed me to use simple css to hide row when empty:

    .leaflet-popup-pane tr:has(td:empty){
    display: none;
}

This behaviour was useful, as it was a simple way to add large amounts of data if present, but also simplify the output when no data available.
Since updating, the empty cells now have the string 'null' inside, breaking the styling. See example image:
image
Related to #1858 ?

To Reproduce
update to latest version of folium

m = Map()
gdf= gpd.read_file(geopackagePath, layer='groupedData')
data = gdf.drop('geometry', axis=1)
popup = folium.GeoJsonPopup(fields=data.columns.tolist(), labels=True, class_name="mystyle")
mapDataFrame= gdf.copy()
mapDataFrame['index'] = mapCopy.index
geojson = folium.GeoJson(data=mapDataFrame, popup=popup)
m.add_child(geojson)
[ Include a data sample or link to your data if necessary to run the code ]

Expected behavior
Empty cell should be empty in the popup

Environment (please complete the following information):

  • Browser chrome, firefox
  • html files
  • Python version sys.version_info(major=3, minor=11, micro=9, releaselevel='final', serial=0)
  • folium version: 0.17.0
  • branca version:0.7.2

Possible solutions
I haven't found a simple solution yet. I had a look at the source, but not sure where the actual change occurred.

@Conengmo
Copy link
Member

Thanks for the report! Just by reading it, it seems to make sense that that change affected it. I think the desired behavior is to not show "null" strings, but show an empty field instead. Someone should look into how we can do that. Ideally we do that close to the part where the data is displayed.

@Conengmo Conengmo added the bug An issue describing unexpected or malicious behaviour label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue describing unexpected or malicious behaviour
Projects
None yet
Development

No branches or pull requests

2 participants