简体   繁体   English

我想在 folium map 中添加一个图例到下面的代码中

[英]I want to add a legend in folium map to the code below

m = folium.Map(location=[39.735,-84.15],zoom_start=10.5)
for idx, row in gdf1.iterrows():
    folium.Marker([row['Latitude'], row['Longitude']], popup=row['Name'], 
icon=folium.Icon(color=row['Colors'])).add_to(m)

This code shows the following output此代码显示以下 output

在此处输入图像描述

I want to make a legend that will say the blue marker represent 'other hospitals' and the red marker represent 'dayton'我想制作一个图例,蓝色标记代表“其他医院”,红色标记代表“代顿”

Please have a look here in this related post Create a Legend on a Folium map请在此处查看相关帖子在 Folium 上创建图例 map

There are two possibilities mentioned:提到了两种可能:

  • using layercontrol with colors (would mean you use multiple MarkerCluster)将 layercontrol 与 colors 一起使用(意味着您使用多个 MarkerCluster)
  • just adding an image as an overlay with your text and color只需将图像添加为带有文本和颜色的叠加层

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM