[英]How Can I return a specific attribute using MarkerClusterGroup in Leaflet?
In leaflet there is a an extension called : Leaflet.markercluster In this extension, there is a function called markerClusterGroup that clusters and returns the count of multiple Markers (points). 在Leaflet中,有一个扩展名为:Leaflet.markercluster。在此扩展中,有一个名为markerClusterGroup的函数,该函数聚集并返回多个Marker(点)的计数。 see example : Here .
看例子: 这里 。
In my example I'm doing the same thing for my polygons centroids, that I calculated using turf. 在我的示例中,我对使用草皮计算出的多边形质心执行相同的操作。 Each of my polygon has an attribute "Inhabitants" which represents the total inhabitants in the polygon.
我的每个多边形都有一个“居民”属性,它代表多边形中的全部居民。 ( this looks like the example i'm working on )
( 这看起来像我正在处理的示例 )
The method markerClusterGroup returns the count of centroids in my example. 在我的示例中,方法markerClusterGroup返回质心的计数。 Can I modify the method to modify the returned value into an aggregation of inhabitants ?
我可以修改将返回值修改为居民集合的方法吗? If no, is there any library you know of capable of aggregating polygons on a specific attribute ?
如果没有,您是否知道可以在特定属性上聚合多边形的库?
Have a look at the "Customising the clustered markers" section of the plugin Readme page. 看一下插件自述文件页面的“定制集群标记”部分。
It shows how the default cluster icon is generated. 它显示了如何生成默认群集图标。 From there you can modify it to sum your child centroid markers property instead of just the count of child markers.
在这里,您可以对其进行修改以汇总子质心标记属性,而不仅仅是子标记的计数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.