Reputation: 53
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
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
}
Upvotes: 6