我想通过转换界面进行自定义转弯。因此,我需要每个步骤的位置来实时计算距离。但似乎iOS7 Directions API不会在响应中公开位置。
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(@"---------------------------------------------------------------------------------");
}
}];
答案 0 :(得分:3)
尝试使用此代码查找每个步骤的位置:
step.polyline.coordinate
此外,在response
参数中,有路径的来源和目的地。