1

When I make a directions request the Completion Handler is never triggered. The CL / MK Placemarks are properly populated and injected into the MKDirections object. Not sure how to proceed with debugging this. Any help?

Below is the method :

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

}
J J
  • 134
  • 1
  • 1
  • 11

0 Answers0