4

In my project i need to show my user travelled path from start to end with car moving animation in map. I already show those locations & draw a route line successfully.

Now i want to animate or move the annotation from start to end.

I tried below code to move the annotation.

- (IBAction)btnClick:(id)sender {
    MKPointAnnotation *point=[[MKPointAnnotation alloc]init];
    [self animateAnnotation:point];
}
-(void) animateAnnotation:(MKPointAnnotation*)annotation{

    CLLocationCoordinate2D newCordinates;
    for(int i=0;i<latArr.count;i++){
        newCordinates=CLLocationCoordinate2DMake([latArr[i] doubleValue], [longArr[i] doubleValue]);
        [UIView
         animateWithDuration:2.0
         delay:2.0
         options:UIViewAnimationOptionCurveEaseInOut
         animations:^{
                         annotation.coordinate = newCordinates;
                     }
                     completion:nil];
    }
}

In this i added all locations & drawed the route(greenline)

enter image description here

This when i click the move annnotaion but i comming from some other locations.

enter image description here

vaibhav
  • 4,038
  • 1
  • 21
  • 51
Test iOS
  • 175
  • 2
  • 13

0 Answers0