我做了一个演示项目(来自github上的Moving-MKAnnotationView演示),用于在地图上移动汽车以下是它的链接
https://github.com/pratikbhiyani/Moving-MKAnnotationView
我在vinaut的给定答案的基础上编辑我的代码,但问题是,当我们缩放或滚动地图动画时,在我们缩放或滚动地图注释设置为其原始角度一段时间时,在ios 7和ios 6中分散注意力.
下面是我的演示项目的屏幕截图

这是我改变的一些代码
- (void) setPosition : (id) posValue;
{
NSLog(@"set position");
//extract the mapPoint from this dummy (wrapper) CGPoint struct
MKMapPoint mapPoint = *(MKMapPoint*)[(NSValue*)posValue pointerValue];
CLLocationCoordinate2D coord = MKCoordinateForMapPoint(mapPoint);
CGPoint toPos;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
toPos = [self.mapView convertCoordinate:coord toPointToView:self.mapView];
}
else
{
CGFloat zoomFactor = self.mapView.visibleMapRect.size.width / self.mapView.bounds.size.width;
toPos.x = mapPoint.x/zoomFactor;
toPos.y = mapPoint.y/zoomFactor;
}
[self setTransform:CGAffineTransformMakeRotation([self getHeadingForDirectionFromCoordinate:MKCoordinateForMapPoint(previousPoint) toCoordinate: MKCoordinateForMapPoint(mapPoint)])];
if (MKMapRectContainsPoint(self.mapView.visibleMapRect, mapPoint)) {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; …Run Code Online (Sandbox Code Playgroud)