I'd like to include an anchor tag in a Folium Marker popup so that I can click through to another page.
Here's my code:
def poptext(row):
return "<a href=\"" + row['Feed'] + "\">" + row['Name'] + "</a>"
map = folium.Map(location=[52.620,-0.264], zoom_start=14)
df.apply(lambda row: folium.Marker([row['Lat'], row['Lon']],popup=poptext(row)).add_to(map), axis =1)
map
Unfortunately, the HTML doesn't seem to be evaluated. Any solution?
Best Answer
You should check the Folium version you are using. 0.2.0 has changed how popups are added, as explained in this issue thread: https://github.com/python-visualization/folium/issues/360
Popups now no longer take html automatically but rather one must pass in a
folium.element.IFrame
of the html.This notebook shows the differences in folium 0.2.0: http://nbviewer.jupyter.org/github/bibmartin/folium/blob/issue288/examples/Popups.ipynb
And, the code would look something like this (found in the notebook above):
NB: The way to create markers, therefore, is no longer
simple_marker
orcircle_marker
, but ratherfolium.Marker
orfolium.CircleMarker()
.The docs have also been (recently?) put up.