我们如何获得工具提示和弹出窗口来显示在对开本中

2024-04-26 18:53:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试获取工具提示和/或弹出窗口,以在地图上显示。当我放大时,我看到的就是这些

enter image description here

下面是我正在测试的代码

import folium
import requests
from xml.etree import ElementTree
from folium import plugins

m = folium.Map(location=[40.6976701, -74.2598704], zoom_start=10)
m.save('path')
for lat,lon,name,tip in zip(df_final['Latitude(DecDeg)'], df_final['Latitude(DecDeg)'], df_final['Market Description'], df_final['Project Description']):
    folium.Marker(location=[lat,lon], tooltip = tip, popup = name)
m.add_child(cluster)
m

我觉得我错过了一个图书馆,或者类似的东西。你知道这为什么不能正常工作吗


Tags: 工具namefromimportdf地图locationdescription
1条回答
网友
1楼 · 发布于 2024-04-26 18:53:01

您似乎忘记使用.add_to(m)将其添加到映射

folium.Marker(...).add_to(m)

marker = folium.Marker(...)
marker.add_to(m)

最低工作代码:

import folium
import webbrowser  # open file in webbrowser

m = folium.Map(location=[40.6976701, -74.2598704], zoom_start=10)

marker = folium.Marker(location=[40.6976701, -74.2598704], 
                       tooltip='<b>Stackoverflow</b><br><br>2021.01.01', 
                       popup='<h1>Happy&nbsp;New&nbsp;Year!</h1><br><br>www:&nbsp;<a href="https://stackoverflow.com">Stackoverflow.com</a><br><br>date:&nbsp;2021.01.01')
marker.add_to(m)

m.save('map.html')

webbrowser.open('map.html')  # open file in webbrowser

enter image description here

相关问题 更多 >