Oksana
Oksana

Reputation: 13942

How to animate the movement of anotations on the MKMapView

How to animate the movement of annotations on the MKMapView? When position of annotation is changed, then annotation moving to other position with animation?

Upvotes: 5

Views: 4611

Answers (2)

Pavel Alexeev
Pavel Alexeev

Reputation: 6081

This question has the answer.

Simply wrapping coordinate change in UIView animateWithDuration seems to work fine:

[UIView animateWithDuration:0.3f
                 animations:^{
    myAnnotation.coordinate = newCoordinate;
}]

Upvotes: 15

Srikar Appalaraju
Srikar Appalaraju

Reputation: 73608

You need to use these delegate methods for that setRegion:animated: & regionThatFits:

[mapView setRegion:region animated:YES];
[mapView regionThatFits:region];

Also mind you that the map update doesn't work with animation when using SIMULATOR. When you try setCenterCoordinate:animated: on the device, it does work with animation.

Upvotes: -3

Related Questions