我使用这个ios-sdk-examples > ClusteringExample来聚集标记,除了这个例子,我需要为每个标记显示不同的UIImages(意味着每个标记都有它自己的UIImage),我有尝试以下操作:iOS - 带集群的Mapbox,MGLSymbolStyleLayer不显示自定义图像
let source = MGLShapeSource(identifier: "clusteredPorts", features: self.features, options: [.clustered: true, .clusterRadius: 22])
style.addSource(source)
// remoteImages is an array of tuple [(image: UIImage, key: String)]
remoteImages.forEach { item in
mapView.style!.setImage(item.image, forName: item.key)
let layer = MGLSymbolStyleLayer(identifier: item.key, source: source)
layer.iconImageName = MGLStyleValue(rawValue: item.key as NSString)
layer.predicate = NSPredicate(format: "%K != YES", "cluster")
style.addLayer(layer)
}
但上面的代码显示了所有非集群标记(截图附后),任何想法,我需要指定这些自定义图像一个单一的UIImage?
更新-1: self.features是一个数组[MGLPointFeature]
,每个MGLPointFeature
具有不外乎以下几点:
let feature = MGLPointFeature()
feature.coordinate = CLLocationCoordinate2D(latitude: LatValue, longitude: LngValue)
feature.attributes = ["id": IntegerValue]
哪里可以解决这个问题? –