skitterm

AGSRouteTaskDelegate never entering delegate methods on solve

Discussion created by skitterm on Jan 31, 2014
Latest reply on Feb 3, 2014 by DGoyal-esristaff
I'm getting a routing service up and running. But after setting up my AGSRouteTask and AGSRouteTaskParams with some stops, my app never enters either the success or failure method of the AGSRouteTaskDelegate.

I have my mapview, agsroutetask, and routetaskparameters as properties.
In my viewDidLoad, I load in the basemap, which displays as it should.
Then in mapViewDidLoad, I set the routetask and routetask params, input some test values for stops, and solve, as shown:


- (void)mapViewDidLoad:(AGSMapView *)mapView {
    
    //set up the routeTask
    NSError *error = nil;
    self.task = [AGSRouteTask routeTaskWithDatabaseName:@"new_file_geodatabase" network:@"sidewalks_ND" error:&error];
    self.task.delegate = self;
    

    //set up the routetaskparameters
    self.params = [AGSRouteTaskParameters routeTaskParameters];
    [self.task retrieveDefaultRouteTaskParameters];
    
    NSMutableArray *stopsMutArr = [[NSMutableArray alloc] init];
    AGSPoint *ptOne = [AGSPoint pointWithX:-111.55 y:40.23 spatialReference:self.mapView.spatialReference];
    AGSSymbol *symbOne;
    symbOne.color = [UIColor greenColor];
    AGSStopGraphic *startPt = [AGSStopGraphic graphicWithGeometry:ptOne symbol:symbOne attributes:nil];
    
    [stopsMutArr addObject:startPt];
    
    AGSPoint *ptTwo = [AGSPoint pointWithX:-111.6 y:40.25 spatialReference:self.mapView.spatialReference];
    AGSSymbol *symbTwo;
    symbTwo.color = [UIColor greenColor];
    
    AGSStopGraphic *endPt = [AGSStopGraphic graphicWithGeometry:ptTwo symbol:symbTwo attributes:nil];
    [stopsMutArr addObject:endPt];
    
    NSArray *stopsArr = [stopsMutArr copy];
    

    AGSGraphicsLayer *graphicsLayer = [AGSGraphicsLayer graphicsLayer];
    
    [graphicsLayer addGraphics:stopsArr];
    
    [self.mapView addMapLayer:graphicsLayer];
    
    [self.params setStopsWithFeatures:stopsArr];
    
    self.params.returnStopGraphics = YES;
    self.params.returnRouteGraphics = YES;
    
    [self.task solveWithParameters:self.params];
    

}

- (void)routeTask:(AGSRouteTask *)routeTask operation:(NSOperation *)op didSolveWithResult:(AGSRouteTaskResult *)routeTaskResult {
    NSLog(@"Navigation worked!");
}

- (void)routeTask:(AGSRouteTask *)routeTask operation:(NSOperation *)op didFailSolveWithError:(NSError *)error {
    NSLog(@"Error: %@", error);
}


- (void)routeTask:(AGSRouteTask *)routeTask operation:(NSOperation *)op didRetrieveDefaultRouteTaskParameters:(AGSRouteTaskParameters *)routeParams {
    self.params = routeParams;
}



The problem is, my application never gets into either my didSolveWithResult or didFailSolveWithError methods. My app keeps running as it did before, as if nothing happened. I've set myself as the routetaskdelegate and am implementing the required method.

Am I missing something?

Outcomes