问题描述
我有很多功能,它们都有一个类别。这可以是“5020”或“5021”。我把它作为 Nsstring 放在特性的属性中。
现在我想添加到我的集群属性中,我有两个布尔值“only_5020”和“only_5021”。因此,如果只存在一个类别,则正确的 bool 应该为真。
我正在尝试为此使用此表达式:
NSExpression(mglJSONObject: ["all",["==",["get","category"],"5020"]])
但它总是错误的。此外,如果我输入“any”而不是“all”,它也是错误的(但我的功能肯定有类别 5020 可用)。
我的整个来源看起来像这样:
let source = MGLShapeSource(identifier: Constants.cluster_source,features: features,options: [.clustered: true,.clusterRadius: 50,.maximumZoomLevelForClustering: Constants.cluster_max_zoom,.clusterProperties: ["5019_only": [NSExpression(mglJSONObject: ["all",5019]]),NSExpression(forConstantValue: "unkNown")],"5020_only": [NSExpression(mglJSONObject: ["all",5020]]),"5021_only": [NSExpression(mglJSONObject: ["all",5021]]),"5022_only": [NSExpression(mglJSONObject: ["all",5022]]),NSExpression(forConstantValue: "unkNown")]]])
style.addSource(source)
我手动创建了这样的功能:
var feature: MGLPointFeature {
get {
let item = MGLPointFeature()
item.identifier = self.itemId
item.attributes["name"] = self.itemTitle
item.attributes["category"] = self.cyclingType.rawValue
item.attributes["isRoute"] = true
item.coordinate = self.coordinate
return item
}
}
有人知道发生了什么吗? 我在 iOS 上使用 mapBox 5.9.0。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)