IOS MapBox聚类点,其中标签来自自定义点字段的总和

问题描述 投票:-1回答:1

如何基于点域创建聚类标题?

例如。我在属性中有一个带有值的点-“ count”

并且从这些点创建聚类时,我想查看包含“计数”字段总和的聚类圆文本,如下所示:

enter image description here

{
    "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”但是我需要使用群集中所有点的值总和

ios swift mapbox mapbox-gl mapbox-ios
1个回答
0
投票

有解决方案:

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]
© www.soinside.com 2019 - 2024. All rights reserved.