在地图应用程序上工作时,我想查找到达目标点的预期时间,而不使用任何类似于maps.google的api。 有什么帮助吗?
以下是代码:
MKPlacemark* placemark = [[MKPlacemark alloc] initWithCoordinate:new_coordinate addressDictionary:nil];
MKMapItem* destinationMapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
MKDirectionsRequest *request = [MKDirectionsRequest new];
request.source = [MKMapItem mapItemForCurrentLocation];
request.destination = destinationMapItem;
request.transportType = MKDirectionsTransportTypeAutomobile;
MKDirections *directions = [[MKDirections alloc] initWithRequest:request];
[directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {
MKRoute *route = response.routes.firstObject;
NSMutableString *Str = [NSMutableString new];
int counter = 1;
for (MKRouteStep *step in route.steps) {
[Str appendFormat:@"%d %@", counter, step.instructions];
counter++;
}
}];
没有给出错误但在calculateDirectionsWithCompletionHandler
内没有调用部分..