qetinac
qetinac

Reputation: 53

how to display Single Location on mapview in iOs?

How can I display single location with longitude and latitude coordinates on mapview (NOT my current location!)?

I want to display only single Location with these random coordinates- When these coordinates change, the old position on map view has to be removed and replaced with new coordinates? How can I do that ?

Upvotes: 1

Views: 1169

Answers (1)

Rob
Rob

Reputation: 438162

To add an annotation:

let annotation = MKPointAnnotation()
annotation.title = title
annotation.coordinate = coordinate
mapView.addAnnotation(annotation)

You can then either remove it with removeAnnotation and add a new annotation, or you can animate its moving to a new coordinate:

UIView.animateWithDuration(1.0) {
    annotation.coordinate = newCoordinate
}

NY to LA

Upvotes: 6

Related Questions