【问题标题】:IOS MapBox clustering point with label from sum by custom points fieldIOS MapBox聚类点,标签来自自定义点字段的总和
【发布时间】:2020-03-21 09:28:03
【问题描述】:

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

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

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

{
    "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”制作文本标题 但我需要使用集群中所有点的值的总和

【问题讨论】:

  • 你的问题有点不清楚,但你看到了吗? docs.mapbox.com/ios/maps/examples/clustering
  • 是的。他们使用“point_count”值作为集群标题。 numbersLayer.text = NSExpression(format: "CAST(point_count, 'NSString')") 但我需要使用集群中所有点的值的总和

标签: ios swift mapbox mapbox-gl mapbox-ios


【解决方案1】:

有解决办法:

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]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-01
    • 2013-04-15
    • 2011-12-24
    • 1970-01-01
    • 2015-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多