- (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; }
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.