MapLibre/Mapbox - 使用集群内的要素属性创建 clusterProperty

问题描述 投票:0回答:0

鉴于集群中的每个功能都有 2 个属性:priority 和 iconName。

我想在 Mapbox/Maplibre 中创建一个名为“clusterIcon”的自定义 clusterProperty,这将是具有最高优先级值的功能的图标。

下面是定义clusterProperties的文档。

The first object determines how the attribute values are accumulated from the cluster points. It is an NSExpression with an expression function that accepts two or more arguments, such as sum or max. The arguments should be featureAccumulated and the previously defined feature attribute key. The resulting value is assigned to the specified attribute key.

The second NSExpression in the array determines which attribute values are accessed from individual features within a cluster.

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]

我怎样才能做到这一点?请注意,我无法创建映射表,因为图标及其优先级并不总是唯一的。

我可以获取最大优先级值,但无法继续获取相关图标。请帮忙!

mapbox mapbox-gl mapbox-ios maplibre-gl mapbox-ios-maps
© www.soinside.com 2019 - 2024. All rights reserved.