简体   繁体   English

如何在Leaflet中使用MarkerClusterGroup返回特定属性?

[英]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.

相关问题 如何使用传单markerclusterGroup? - How to use leaflet markerclusterGroup? 如何打开 leaflet MarkerClusterGroup 中特定标记的弹出窗口? - How to open popup for a specific marker inside a leaflet MarkerClusterGroup? 如何通过 Leaflet.MarkerClusterGroup 中的 ID 删除标记 - How to REMOVE a marker by ID in Leaflet.MarkerClusterGroup 使用MarkerClusterGroup在Leaflet中先前创建的图层上添加标记时,标记位置会累积 - Marker locations accumilate when adding a marker on a previously created Layer in Leaflet using MarkerClusterGroup 防止多个markerClusterGroup图标在Leaflet中重叠 - Prevent multiple markerClusterGroup icons from overlapping in Leaflet 传单:未捕获的类型错误:L.markerClusterGroup 不是函数 - Leaflet: Uncaught TypeError: L.markerClusterGroup is not a function 如何返回带有参数的属性值? - How can I return an attribute value with argument? 如何使用 leaflet 在 map 上画一条实线? - How can I draw a continuous line on map using leaflet? 如何在 React Leaflet 中使用 onEachCountry 刷新 GeoJSON choropleth? - How can I refresh GeoJSON choropleth using onEachCountry in React Leaflet? 如何将R中的传单地图输出为可以使用Leaflet命令进行编辑的格式? - How do I output leaflet map from R into format where I can edit using Leaflet commands?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM