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.

Folium map not rendering when Marker 'popup' specified?

See original GitHub issue

Apologies, 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:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

13reactions
ocefpafcommented, Sep 18, 2017

The problem is with the popup text. Latest version of folium takes raw HTML for simplicity, a feature that many wanted for a while, so when your text has ' or &, for example, you need to use parse_html=True, see http://nbviewer.jupyter.org/gist/ocefpaf/d1d612d290f766935d8abe1559523a72

3reactions
jpeacock29commented, Nov 21, 2017

Shouldn’t this at least be documented in folium.map.Marker?

Read more comments on GitHub >

github_iconTop 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 >

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