question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding geojson properties to popup

See original GitHub issue

I have the following code which uses this geojson file as input.

import folium
markers_geojson='volcanoes_json.geojson'  
map=folium.Map(location=[0,0],zoom_start=6,tiles='Mapbox bright')
map.add_child(folium.GeoJson(data=open(markers_geojson),name='Volcano').add_child(folium.Popup("A plain pop up string")))    
map.save(outfile='test5.html')

As you see the code is simply displaying a static string. Is there a way to put marker properties values contained in the json file in the popup method?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
ghostcommented, Jul 4, 2016

Thanks a lot for your help.

FeatureGroup worked well. The map now has popups and a layer control. Here is the code for future reference:

import folium
import pandas
df=pandas.read_csv("Volcanoes_USA.txt")

map=folium.Map(location=[df['LAT'].mean(),df['LON'].mean()],zoom_start=6,tiles='MapQuest Open Aerial')

fg=folium.FeatureGroup(name="Pika")

for lat,lon,name,elev in zip(df['LAT'],df['LON'],df['NAME'],df['ELEV']):
    fg.add_child(folium.Marker(location=[lat,lon],popup=(folium.Popup(name))

map.add_child(fg)

map.add_child(folium.LayerControl())

map.save(outfile='fg1.html')
4reactions
fnorfcommented, Feb 6, 2017

Any reading through these, be careful about calling your map “map”. map is a built-in function in Python and you would overwrite the name. Use “m”, like in the folium docs to avoid confusion. 😉 https://docs.python.org/3/library/functions.html#map

Read more comments on GitHub >

github_iconTop Results From Across the Web

Displaying properties of GeoJSON in popup on Leaflet?
This is my simple GeoJSON with Leaflet map. I want to display properties as popup but I don't know why it is empty....
Read more >
Leaflet Popup with additional information from GeoJSON
Assuming the service returns data with similar properties as the polygon, you can indeed add them to one and the same layer.
Read more >
Leaflet Map with GeoJSON popups
getJSON("map.geojson", function(data) { function onEachFeature(feature, layer) { layer.bindPopup("Name: " + feature.properties.name + "<br>" + "Population: ...
Read more >
Using GeoJSON with Leaflet
GeoJSON objects are added to the map through a GeoJSON layer. To create it and add it to a map, we can use...
Read more >
Leaflet Examples
Example 6: Adding points from a geojson file with popups - Change popup values (this is inside the GeoJSON file). Example 7: Adding...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found