0

Using python I have managed to extract the exref data (lat, long, etc) of photos into a pandas dataframe. I then generate a leaflet/folium map html file, which when opened in a browser, displays the georeferenced points where the photos were captured. Clicking each opens a popup displaying filename, as per the following:

for lat,lon,Filename in zip(df['Lat'],df['Lon'],df['Filename']):
  fg.add_child(folium.Marker(location[lat,lon],popup=Filename,icon=folium.Icon(color='red')))

However, what I would like to do is display the actual images in the popup. Is it possible to do this with locally stored images - perhaps by specifying the filepath+filename? Web searches have returned a number of solutions for using web-hosted images by referring to url's, but I would like to use this as a way to navigate through offline photos if possible.

Happy to hear of alternative solutions if this simply isn't an option with Leaflet.

EllRob
  • 145
  • 1
  • 3
  • 11

2 Answers2

0

Since popup takes a string, wouldn't fg.add_child(folium.Marker(location[lat,lon],popup="<img src='file:///"+MY_FILE_PATH + Filename + "'>",icon=folium.Icon(color='red'))) work well for your scenario?

snkashis
  • 2,951
  • 1
  • 18
  • 35
  • Thanks, I gave this a try, but it appears to just display the string as entered - no image. When I click on a popup, the following text is shown: – EllRob Mar 19 '17 at 19:46
  • Sounds like Folium is dumping that string as text, not html into the popup. Can you construct the img tag with `Element` instead, and pass that into the popup? http://python-visualization.github.io/folium/module/element.html#html – snkashis Mar 20 '17 at 17:35
0

For anyone else looking, I eventually managed to get this working through a combination of snkashis's suggestions and the instructions contained within the following thread:

https://github.com/python-visualization/folium/issues/604:

EllRob
  • 145
  • 1
  • 3
  • 11