【问题标题】:How to insert a both an image and text in a Folium marker如何在 Folium 标记中插入图像和文本
【发布时间】:2020-09-16 15:12:42
【问题描述】:

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

arch_map = folium.Map(location=coord_città, zoom_start=11)
#creating map with folium with tooltips which are the information 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') 


【问题讨论】:

    标签: python marker folium


    【解决方案1】:

    在 iframe 中,您可以使用不同的 HTML 标签。在您的情况下,您可以使用 figure 和 figurecaption 标签在标记中添加建筑物名称:

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多