我想使用 Folium 在地图上做一些标记,并在标记内添加一些数字。
我希望标记看起来像 Google 地图使用的标准倒置水滴形状。
我看到对于 folium.Marker,您可以使用参数 icon=folium.DivIcon("html code here"),但我不知道如何制作 html 代码,使标记看起来像倒置的水滴标准标记。
我在这里看到了一个很好的例子,使用 leaflet.js:https://github.com/iatkin/leaflet-svgicon,这是他们的演示:http://iatkin.github.io/leaflet-svgicon/.
我只是不知道如何在Python 中实现它。
我想要放置在标记内的数字是某种具有 3 个字符(1 位数字、一个点和一个小数)的评级数字,例如 3.4、4.8、2.5 等。值从 0.0 到 5.0 。
这种类型的标记形状也很好:
我看到了像这个例子这样的其他解决方案,它们显示圆圈并显示内部的数字,但它看起来不像常规的尖头图钉标记那样好:Folium 地图标记中的数字
Thanks,
Steven
你好,我做了类似的事情,结果如下:
代码是:
import folium
import folium.plugins as plugins
# BASE MAP
n = folium.Map(location=[20.299172882895903,-103.18423327532622], zoom_start = 10)
for i in range(0,len(DF)):
html=f"""
<h2> Información de la ruta </h2>
<p> Ruta: {DF.iloc[i]['route_id']} </p>
<p> Secuencia de visita: {DF.iloc[i]['sequencia']} </p>
"""
iframe = folium.IFrame(html=html, width=200, height=150)
popup = folium.Popup(iframe, max_width=650)
folium.Marker(
location=[DF.iloc[i]['latitude'], DF.iloc[i]['longitude']], popup=popup,
icon=plugins.BeautifyIcon(
icon="arrow-down", icon_shape="marker",
number=DF.iloc[i]['sequencia'],
border_color= itinerario_lunes.iloc[i]['hex_code'],
background_color=itinerario_lunes.iloc[i]['hex_code']
)
).add_to(n)
# Show the map again
n
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)