如何在Folium标记中同时插入图像和文本

问题描述

我最近开发了一个程序,该程序从“ Archinform”中获取有关特定城市的建筑作品的数据,然后继续抓取所需的数据,然后绘制地图。 我一直在插入有关建筑物的信息作为工具提示,并插入图像作为标记。 如何将建筑物名称添加标记中? 我将在下面添加我的代码

arch_map = folium.Map(location=coord_città,zoom_start=11)
#creating map with folium with tooltips which are the @R_807_4045@ion of the place and markers which are the images

for lat,lng,name,label in zip(valid_xcoords,valid_ycoords,google_names,project_info):
    if lat != 0:
        html = '<img src="data:image/jpeg;base64,{}">'.format
        encoded = base64.b64encode(open(name+' '+cit+'.jpg','rb').read()).decode()
        iframe = folium.IFrame(html(encoded),width=300,height=150)
        tooltip = folium.Popup(iframe)
        icon=folium.IFrame('<i class="fas fa-archway"></i>')
        folium.Marker([lat,lng],tooltip=label,popup=tooltip,icon=folium.Icon(color='orange',icon='university',prefix='fa')).add_to(arch_map)

arch_map.save('Mappa di '+cit+'.html') 


解决方法

在iframe中,您可以使用其他HTML代码。就您而言,您可以使用图形和图形标题标签在标记中添加建筑物名称:

html = '<figure>'
encoded = base64.b64encode(open(name+' '+cit+'.jpg','rb').read()).decode()
html += '<img src="data:image/jpeg;base64,{}">'.format(encoded)
html += '<figcaption>{}</figcaption></figure>'.format(building_name)