Mapbox 在集群中显示累积属性

Mapbox 在集群中显示累积属性,mapbox,mapbox-gl-js,Mapbox,Mapbox Gl Js,因此,我目前在Mapbox示例的帮助下对地图上的点网格进行聚类: Mapbox中的示例代码计算点数并如下所示-使用变量point\u count\u缩写: map.addLayer({ id: "cluster-count", ... layout: { "text-field": "{point_count_abbreviated}", },

因此,我目前在Mapbox示例的帮助下对地图上的点网格进行聚类:

Mapbox中的示例代码计算点数并如下所示-使用变量
point\u count\u缩写

map.addLayer({
      id: "cluster-count",
      ...        
      layout: {
        "text-field": "{point_count_abbreviated}",
         },
       ...
    })
我的geoJSON源代码如下所示:

  {
  "type": "Feature",
  "geometry": { ... },
  "properties": {
    "location": { ... },
    "id": 111,
    ...
    "value": {
      "count": 2
    }
  }
}
我想做的是将所有“properties.value.count”相加, 并显示每个群集上的总和。 我已经试过书中的例子了 但是由于我的count变量嵌套在value对象中, 我很难做到这一点

我猜在集群源定义中是这样的:

clusterProperties: {"sum": ["+", ["object", "value", ['get, 'count']]]}
并将其显示在图层中:

layout: {
            "text-field": ['get', 'sum'],
             },

有人能给我指一下正确的方向吗?:)

我设法做到了这一点。逻辑是这样的: 获取属性对象内的值对象内的计数变量。 属性对象是所述的保留表达式

在来源的定义中:

clusterProperties: {
  sum: ["+", ["get", "count", ["get", "value", ["properties"]]]],
},
在显示总和的图层中:

"text-field": ["get", "sum"],

谢谢分享这个方法。我想为正在处理转换(CSV到GeoJSON)数据的用户添加一个详细信息。我花了几个小时寻找将数字字段转换为整数的解决方案。所有数据都转换为字符串,csv2geojson的官方网页中没有关于如何转换的信息。最后,我添加了->数字字段:“客户”选项,它对我很有用

  function makeGeoJSON(csvData) {
    csv2geojson.csv2geojson(csvData, {
      latfield: 'Latitude',
      lonfield: 'Longitude',          
      delimiter: ',',
      numericFields: 'customers',
      cluster: true,
      clusterMaxZoom: 14,
      clusterRadius: 50,

    }, function (err, data) {
      map.on('load', function () {
        map.addSource('geopoints', {
          type: 'geojson',
          data: data,
          cluster: true,
          clusterMaxZoom: 14,
          clusterRadius: 50, 
          clusterProperties: {
            sum: ["+", ["get", "customers", ["properties"]]],
          },
        });