qetinac qetinac - 1 year ago 41
iOS Question

how to display Single Location on mapview in iOs?

How can i display single Location with Longitude, Latitude coordinates on Mapview (NOT my current location!)? I want to display only single Location with these random coordinates- When these coorditanes change, the old position on map view has to be removed and replaced with new coordinates? How can i do that ?


Rob Rob
Answer Source

To add an annotation:

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

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

enter image description here