简体   繁体   English

是否可以在传单地图弹出窗口中显示本地保存的图像?

[英]Is it possible to display locally saved images in Leaflet map popups?

Using python I have managed to extract the exref data (lat, long, etc) of photos into a pandas dataframe. 使用python,我设法将照片的exref数据(纬度,经度等)提取到熊猫数据框中。 I then generate a leaflet/folium map html file, which when opened in a browser, displays the georeferenced points where the photos were captured. 然后,我生成一个传单/叶片地图html文件,该文件在浏览器中打开时,将显示捕获照片的地理参考点。 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? 是否可以对本地存储的图像执行此操作-也许通过指定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. 网络搜索通过引用url返回了许多使用网络托管图像的解决方案,但我想以此作为浏览脱机照片的方法。

Happy to hear of alternative solutions if this simply isn't an option with Leaflet. 如果这不是Leaflet的选择,那么很高兴听到其他解决方案。

由于popup接受字符串,因此不会fg.add_child(folium.Marker(location[lat,lon],popup="<img src='file:///"+MY_FILE_PATH + Filename + "'>",icon=folium.Icon(color='red')))适合您的情况?

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: 对于其他人,我最终设法通过snkashis的建议和以下线程中包含的说明进行了组合:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM