0

Can you please tell me what I am doing wrong here. I am trying to move the marker the over the route between two directions that I got from the Google Direction API.

Check the code and image behavior.

- (void)mainQueue:(BOOL)update
{
    NSLog(@"main queue");

    GMSPolyline *singleLine;
    GMSPath *path1 =[GMSPath pathFromEncodedPath:self.dataReceive[@"routes"][0][@"overview_polyline"][@"points"]];

    singleLine = [GMSPolyline polylineWithPath:path1];
    self.singleLine.map = nil;
    if(update)
    {

        singleLine.strokeWidth = 7;
        singleLine.strokeColor = [UIColor greenColor];

        singleLine.map = self.mapView;
        self.singleLine = singleLine;
        int j = 0;
        NSArray *steps = [[[self.dataReceive objectForKey:@"routes"][0]objectForKey:@"legs"][0]objectForKey:@"steps"];
        for(j=0; j<steps.count;j++){
            GMSPath *path2 =[GMSPath pathFromEncodedPath:self.dataReceive[@"routes"][0][@"legs"][0][@"steps"][j][@"polyline"][@"points"]];
            for (signed long i = 0; i< path2.count; i++) {

                [CATransaction begin];
                [CATransaction setAnimationDuration:10];
                CLLocationCoordinate2D position = [path2 coordinateAtIndex:i];
                self.marker.position = position;

                [CATransaction commit];
                //self.marker.map = self.mapView;
            }
            self.marker.map = self.mapView;
        }
        circ.map = self.mapView;
    }
}

Check the output:

![enter image description here]1

Nazir
  • 1,945
  • 24
  • 27

0 Answers0