这是我模拟标记移动的代码:
CLLocationCoordinate2D targetCoordinate = [_directionArray objectAtIndex:_currentTargetLocationIndex].coordinate;
CGFloat startLat = _busMarker.layer.latitude;
CGFloat startLon = _busMarker.layer.longitude;
CABasicAnimation *animLat = [CABasicAnimation animationWithKeyPath:@"latitude"];
animLat.fromValue = [NSNumber numberWithFloat:startLat];
animLat.toValue = [NSNumber numberWithFloat:targetCoordinate.latitude];
CABasicAnimation *animLon = [CABasicAnimation animationWithKeyPath:@"longitude"];
animLon.fromValue = [NSNumber numberWithFloat:startLon];
animLon.toValue = [NSNumber numberWithFloat:targetCoordinate.longitude];
CAAnimationGroup *group = [CAAnimationGroup animation];
group.duration = 10;
group.animations = @[animLat, animLon];
group.removedOnCompletion = YES;
[_busMarker.layer addAnimation:group forKey:@"markerMove"];
动画似乎过于波动/迟钝,我确定这不是设备性能问题,因为我试图将类似的动画集成到UIView中,这很酷。
请帮忙谢谢!