1

Here is my code to simulate marker movement :

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"];

The animation seems too choppy/laggy , I'm sure it's not device performance issue because I tried to integrate the similar animation to a UIView and it was cool.

Please help and thank you !.

user3193307
  • 503
  • 1
  • 4
  • 8

0 Answers0