I use this ios-sdk-examples> ClusteringExample for clustered tokens, in addition to this example I need to show different UIImages for each token (meaning that each token has its own UIImage), I tried the following:
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)
}
But the above code shows one single UIImage for all non-clustered markers (attached screenshot), any idea where I need to specify these custom images?
Update-1: self.features is an array [MGLPointFeature], each MGLPointFeaturehas nothing more than the following:
let feature = MGLPointFeature()
feature.coordinate = CLLocationCoordinate2D(latitude: LatValue, longitude: LngValue)
feature.attributes = ["id": IntegerValue]

source
share