我尝试向folium弹出窗口添加图片,但失败了。我使用的是Python 2.7版本和Folium 0.50版本。
实际上,我遵循其他线程中提到的页面,但仍然无法正常工作。
实际上,我遵循其他线程中提到的页面,但仍然无法正常工作。
http://nbviewer.jupyter.org/gist/ocefpaf/0ec5c93138744e5072847822818b4362
import folium
import base64
m = folium.Map(location = [33, -97], zoom_start = 6, tiles = "Mapbox Bright")
encoded = base64.b64encode(open('IMG_1769.JPG', 'rb').read()).decode()
html = '<img src="data:image/jpeg;base64,{}">'.format
iframe = folium.IFrame(html(encoded), width=632+20, height=420+20)
popup = folium.Popup(iframe, max_width=2650)
marker = folium.Marker([30,-100], popup=popup).add_to(m)
m.add_child(marker)
m.save("test.html")
html = '<img src="data:image/jpeg;base64,{}">'.format
的含义?末尾的 'format' 是做什么用的? - chaikov