当我发出指示请求时,永远不会触发完成处理程序。正确填充CL / MK地标并将其注入MKDirections对象。不知道如何继续调试这个。有什么帮助吗?
以下是方法:
-(void)getRouteWithPlacemark:(CLPlacemark*)clPlacemark
{
MKDirectionsRequest *directionsRequest = [[MKDirectionsRequest alloc] init];
MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:clPlacemark];
mapView.showsUserLocation = YES;
if(routeIndex > 0){
[directionsRequest setSource:[[MKMapItem alloc] initWithPlacemark:previousPlacemark]];
}else{
[directionsRequest setSource:[MKMapItem mapItemForCurrentLocation]];
}
previousPlacemark = [[MKPlacemark alloc] initWithPlacemark:placemark];
[directionsRequest setDestination:[[MKMapItem alloc] initWithPlacemark:placemark]];
directionsRequest.transportType = MKDirectionsTransportTypeAutomobile;
MKDirections *directions = [[MKDirections alloc] initWithRequest:directionsRequest];
[directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {
if(error){
NSLog(@"Error %@", error.description);
}else{
routeDetails = response.routes.lastObject;
[mapView addOverlay:routeDetails.polyline];
[self addAnnotation:clPlacemark];
[self populateManeuversArrayWithRoute:routeDetails];
if(routeIndex == [packageArray count] - 1){
[self zoomMap];
indicatorOverlay.hidden = YES;
routeIndex = 0;
}else{
routeIndex++;
[self getDirectionsWithCRMDataPackageArray:packageArray];
}
}
}];
}