我目前正在尝试展示一些来自instagrammapi的图片以及它们在folium中的位置。我要做的是显示在对页中的位置,并使用弹出式标记来显示图片和图片的标题。在
我设法在弹出标记中显示图片,但我不知道如何添加图片文本。在
这是我的代码:
from InstagramAPI import InstagramAPI
from nested_lookup import nested_lookup
import folium
from folium import IFrame
import base64
import requests
image_url=[]
username="username"
InstagramAPI = InstagramAPI(username, "password")
InstagramAPI.login()
InstagramAPI.timelineFeed()
timelinefeed = InstagramAPI.LastJson
image_url_lookup=nested_lookup('candidates', timelinefeed)
for x in range(0,len(image_url_lookup)):
image_url.append(image_url_lookup[x][1]['url'])
html = '<img src="data:image/JPG;base64,{}">'.format
m = folium.Map(location=[20, 0], tiles="Stamen Terrain", zoom_start=12)
encoded = base64.b64encode(requests.get(image_url[1]).content).decode()
iframe = IFrame(html(encoded), width=632+20, height=420+20)
popup = folium.Popup(iframe, max_width=1000)
folium.Marker(location=[72, -40],popup=popup).add_to(m)
m.save("Map_Show.html")
您只需在
html
变量中添加一些文本:相关问题 更多 >
编程相关推荐