【发布时间】:2020-05-09 14:47:32
【问题描述】:
我想让标记层始终保持在前面,但我不知道该怎么做。
只要我开始在“图层控制”窗格中单击和取消单击图层,标记图层就会消失在 choropleth 图层后面。
这是我的代码:
m = folium.Map([40.4165001, -3.7025599], zoom_start=10, tiles='CartoDB Positron', overlay=True)
# folium.TileLayer('cartodbpositron', overlay=True).add_to(m)
income=folium.Choropleth(
geo_data=censo,
data=df1,
name='Household Income 2016',
columns=['CDSSCC', 'HouseholdIncome2016'],
key_on='feature.properties.CDSSCC',
fill_color='BuGn',
fill_opacity=1,
line_opacity=0.2,
highlight=True,
legend=False,
).add_to(m)
pop=folium.Choropleth(
geo_data=censo,
data=df1,
name='Population 2016',
columns=['CDSSCC', 'POB_TOTAL'],
key_on='feature.properties.CDSSCC',
fill_color='YlOrBr',
fill_opacity=1,
line_opacity=0.2,
highlight=True,
legend=False,
).add_to(m)
# add clusters to the map
markers_colors = []
for lat, lon, poi, cluster in zip(buildingsmadrid_merged['Latitude'], buildingsmadrid_merged['Longitude'], buildingsmadrid_merged['Name'], buildingsmadrid_merged['Cluster Labels']):
label = folium.Popup(str(poi) + ' Cluster ' + str(cluster), parse_html=True)
puntos=folium.CircleMarker(
[lat, lon],
radius=5,
popup=label,
tooltip = label,
color='YlOrBr'[cluster-1],
fill=True,
fill_color='YlOrBr'[cluster-1],
fill_opacity=0.7,
overlay=False).add_to(m)
folium.LayerControl(position='topright', collapsed=False, autoZIndex=True).add_to(m)
# m.save(os.path.join('choropleth.html'))
m
感谢您的帮助
【问题讨论】:
-
请提供完整的代码和数据。谢谢。
-
此笔记本包含整个代码。我所指的问题位于创建最终地图的最后。 github.com/martabescansa7/Coursera_Capstone/blob/master/… 非常感谢
标签: python layer markers folium