2014-01-14 57 views
1

我想做一個自定義的輪到界面。所以我需要每一步的位置來實時計算距離。但似乎iOS7 Directions API不會在響應中公開位置。MKRouteStep:位置在哪裏?

MKDirections *directions = [[MKDirections alloc] initWithRequest:directionsRequest]; 
[directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) { 


    MKRoute *firstRoute = response.routes[0]; 
    NSArray *steps = firstRoute.steps; 
    for (MKRouteStep *step in steps) { 
     NSLog(@"---------------------------------------------------------------------------------"); 
     NSLog(@"instruction %@", step.instructions); 
     NSLog(@"notice %@", step.notice); 
     NSLog(@"distance %f", step.distance); 
     NSLog(@"---------------------------------------------------------------------------------"); 
    } 
}]; 

回答

2

試試這個代碼,找出每一步的位置:

step.polyline.coordinate 

此外,在response參數有源和路線的目的地。