如何在谷歌地图iOS中的方向之间的路线上迭代标记?

时间:2017-04-26 11:58:24

标签: ios objective-c google-maps google-maps-markers

你能告诉我这里做错了吗?我试图将标记移动到我从Google Direction API获得的两个方向之间的路线上。

检查代码和图像行为。

- (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;
    }
}

检查输出:

![enter image description here] 1

0 个答案:

没有答案