我使用python中的folium包来显示数据的MarkerClusters。在
当你没有放大所有的方式,集群看起来不错,但他们似乎显示了一个计数的子标记内的集群。我理解为什么这是默认行为,但出于我的目的,我真的希望簇显示给定簇内每个单独标记在缩放级别上的平均值。在
下面是我现在的代码:
folium_map = folium.Map(location=[33.97810188618428, -118.2155395906348])
mc = MarkerCluster()
for p in points:
marker = build_folium_marker(p['f_name'], p['value'], p['lat'], p['lng'])
mc.add_child(marker)
folium_map.add_children(mc)
folium_map.save('folium_marker_cluster_map.html')
在理想的情况下,MarkerCluster会使用一些参数,让您发送“count”或“average”,但事实并非如此。我是谨慎乐观的有人将能够建议一个合理的简单的修复,不涉及分叉传单(js库的折页是建立在)和编辑js源代码。我不是第一个想在MarkerClusters上显示一个不同于sum的度量的人,特别是集群中标记值的平均值。在
要自定义标记簇
icon_create_function
函数,下面的示例演示如何重写标记标签以显示自定义值而不是默认值(簇中的标记数):现在轮到通过marker传递自定义属性了,in Folium default marker不支持它,但是可以引入以下marker类来扩展
^{pr2}$Marker
类:现在在Folium中,一旦marker对象被实例化(其中
population
是一个自定义属性)它的自定义属性可以通过JavaScript访问:
总之,下面是一个示例,演示如何:
示例
结果
相关问题 更多 >
编程相关推荐