Srujan Simha Srujan Simha - 1 year ago 72
Swift Question

Show annotation title automatically

I'm trying to display the annotation title automatically instead of displaying it on tap. I used the below code to display annotation and make it center on map.

self.ann.title = "Title"
self.ann.subtitle = "Subtitle"

self.span = MKCoordinateSpanMake(0.005, 0.005)
self.region = MKCoordinateRegion(center: currentLocation2D, span: self.span)
self.mapView.setRegion(self.region, animated: true)

I get to see the
when I tap the annotation but couldn't able to display it automatically.

Answer Source

You can use it by using selectAnnotation and use the mapview.annotations array, which contains all your annotations which you have on your map.

let yourAnnotationAtIndex = 0
mapView.selectAnnotation(mapView.annotations[yourAnnotationAtIndex], animated: true)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download