I am working on an application which use user location updates, I have got the current latitude and longitude and display the current location of the user and annotate the pin, However I need help regarding moving a pin when user changes his location or when user moves and get new latitude and longitude the pin should also move to that position.
Share
To show the current location, you could just set
showsUserLocationto YES and let the map show the blue dot for you.If you want to show your own annotation instead and have it move automatically, implement
setCoordinate:in the class that implements theMKAnnotationprotocol.Then when the coordinates change, update the annotation’s coordinate and the map view will automatically (via KVO) move the annotation’s view/pin.
You could also remove the annotation and create a new one at the new location but that can result in flicker.
If you are using Core Location to get location updates, you would update the annotation’s coordinates in the
locationManager:didUpdateToLocation:fromLocation:delegate method.