Closed rgdev closed 7 years ago
I found a solution. I wasn't able to get my annotations because those are wrapped in a CKCluster.
func onAnnotationStateReceived(_ identifier: Int) {
let myAnnotation = myArray[identifier]
for annotation in map.annotations {
if let cluster = annotation as? CKCluster {
if cluster.contains(myAnnotation) && cluster.count == 1 {
let av = mapview.view(for: cluster) as? MyAnnotationView
av?.updateState()
}
}
}
}
Hello,
I keep an array of my annotations that I give to the clusterManager :
At a later time I would like to access one of my annotation's corresponding annotation view (outside of
mapView(_:viewFor:)
) to update it (basically my annotations have a different visual for different states, state that I obtain after a network call)I've tried something like this :
let av = map.view(for: myArray[0]) as? MyAnnotationView
but I always end up with
nil
value.Any idea why ? Would it be possible to update annotation views without removing/adding them back every time ?
Thanks.