如何基于点域创建聚类标题?
例如。我在属性中有一个带有值的点-“ count”
并且从这些点创建聚类时,我想查看包含“计数”字段总和的聚类圆文本,如下所示:
{
"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”但是我需要使用群集中所有点的值总和
有解决方案:
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]