Folium map not rendering when Marker 'popup' specified?
See original GitHub issueApologies, in advance, if this not the most appropriate place for this question (as this might be a Jupyter Notebook issue)!
Issue
I cannot get Folium to render a map when the ‘popup’ parameter for Marker objects are specified via list indexing (where the list contains strings). What’s confusing is that it works fine if the Marker ‘popup’ is a static string!
Example: Working code
This code works (i.e., a viewable map is rendered) in a Jupyter notebook cell:
# Imports dependency used to drop markers onto a map
import folium
# Isolating "northing" and "easting" information with labels for each point
locationlist = df_nearme[["Latitude","Longitude"]].values.tolist()
labels = df_nearme["Cafe Name"].values.tolist()
# Create map and drop points onto it
m = folium.Map(location=[lat_home, long_home], zoom_start=14)
for point in range(len(locationlist)):
folium.Marker(locationlist[point]).add_to(m)
m
So does this code:
# Imports dependency used to drop markers onto a map
import folium
# Isolating "northing" and "easting" information with labels for each point
locationlist = df_nearme[["Latitude","Longitude"]].values.tolist()
labels = df_nearme["Cafe Name"].values.tolist()
# Create map and drop points onto it
m = folium.Map(location=[lat_home, long_home], zoom_start=14)
for point in range(len(locationlist)):
folium.Marker(locationlist[point], popup='abc123').add_to(m)
m
Example: Not working code
BUT this code does not render a viewable map (no error is thrown, but I just get a blank, white box):
# Imports dependency used to drop markers onto a map
import folium
# Isolating "northing" and "easting" information with labels for each point
locationlist = df_nearme[["Latitude","Longitude"]].values.tolist()
labels = df_nearme["Cafe Name"].values.tolist()
# Create map and drop points onto it
m = folium.Map(location=[lat_home, long_home], zoom_start=14)
for point in range(len(locationlist)):
folium.Marker(locationlist[point], popup=labels[point]).add_to(m)
m
As I mentioned before, I suspect this has something to do with Jupyter Notebook, but I’m not entirely sure and figured I’d ask to see if anyone else has run into this issue.
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
python - Folium map not displaying - Stack Overflow
To display in the iPython notebook, you need to generate the html with the myMap._build_map() method, and then wrap it in an iFrame...
Read more >Folium Mapping: Displaying Markers on a Map
Display single or multiple markers on a folium map with ease. ... This returns the following map centred on the location specified above....
Read more >Folium 0.12.1 documentation
When one clicks on a Map that contains a ClickForMarker, a Marker is created at the pointer's position. Parameters. popup (str, default None)...
Read more >Map with markers with Python and Folium
This blogpost explains how to build an interactive map with markers using Python and Folium . It explains how to add the markers...
Read more >How to plot your data on maps using Python and Folium
Harness the power of Python with data and Leaflet.js on mapping to ... we actually change the marker itself and not only the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The problem is with the
popup
text. Latest version offolium
takes raw HTML for simplicity, a feature that many wanted for a while, so when your text has'
or&
, for example, you need to useparse_html=True
, see http://nbviewer.jupyter.org/gist/ocefpaf/d1d612d290f766935d8abe1559523a72Shouldn’t this at least be documented in
folium.map.Marker
?