0

如何根据点字段创建集群标题?

例如。我在属性中有值的点 - “计数”</p>

从这些点创建集群时,我希望看到带有“计数”字段总和的集群圆形文本,如下所示:

在此处输入图像描述

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "count": 16

            },
            "geometry": {
                "type": "Point",
                "coordinates": [
                    30.5419921875,
                    50.55532498251967
                ]
            }
        },
        {
            "type": "Feature",
            "properties": {
                "count": 2
            },
            "geometry": {
                "type": "Point",
                "coordinates": [
                    36.25488281249999,
                    50.05008477838256
                ]
            }
        }
    ]
}

https://docs.mapbox.com/ios/maps/examples/clustering/ 这个例子从“point_count”制作文本标题但我需要使用集群中所有点的值总和

4

1 回答 1

2

有解决办法:

https://github.com/mapbox/mapbox-gl-native/pull/15515

let firstExpression = NSExpression(format: "sum:({$featureAccumulated, sumValue})")
let secondExpression = NSExpression(forKeyPath: "magnitude")
let clusterPropertiesDictionary = ["sumValue" : [firstExpression, secondExpression]]

let options : [MGLShapeSourceOption : Any] = [.clustered : true,
                                           .clusterProperties: clusterPropertiesDictionary]
于 2020-03-21T15:31:59.800 回答