NSMutableArray *barrierGraphics = [[NSMutableArray alloc] init ]; incidents_barriers = [[AGSGraphicsLayer alloc] init ]; [self.mapView addMapLayer:incidents_barriers withName:@"Incident Barriers"]; for(i=0;i<[incidents.graphics count];i++) { double x = ((AGSGraphic *)[incidents.graphics objectAtIndex:i]).geometry.envelope.center.x; double y = ((AGSGraphic *)[incidents.graphics objectAtIndex:i]).geometry.envelope.center.y; AGSSymbol *symbol; symbol = [self barrierSymbol]; NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; [attributes setValue:[NSNumber numberWithInt:i+1] forKey:@"barrierNumber"]; AGSEnvelope *env = [AGSEnvelope envelopeWithXmin:x-0.001 ymin:y-0.001 xmax:x+0.001 ymax:y+0.001 spatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326]]; AGSGraphic *tempBarrier = [AGSGraphic graphicWithGeometry:env symbol:symbol attributes:nil infoTemplateDelegate:self]; tempBarrier.attributes = attributes; [incidents_barriers addGraphic:tempBarrier]; [barrierGraphics addObject:tempBarrier]; [incidents_barriers dataChanged]; } [params setPolygonBarriersWithFeatures:barrierGraphics]; params.ignoreInvalidLocations = YES; [task solveWithParameters:params];
Solved! Go to Solution.
NSMutableArray *barrierGraphics = [[NSMutableArray alloc] init ]; incidents_barriers = [[AGSGraphicsLayer alloc] init ]; [self.mapView addMapLayer:incidents_barriers withName:@"Incident Barriers"]; for(i=0;i<[incidents.graphics count];i++) { double x = ((AGSGraphic *)[incidents.graphics objectAtIndex:i]).geometry.envelope.center.x; double y = ((AGSGraphic *)[incidents.graphics objectAtIndex:i]).geometry.envelope.center.y; AGSSymbol *symbol; symbol = [self barrierSymbol]; NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; [attributes setValue:[NSNumber numberWithInt:i+1] forKey:@"barrierNumber"]; AGSEnvelope *env = [AGSEnvelope envelopeWithXmin:x-0.001 ymin:y-0.001 xmax:x+0.001 ymax:y+0.001 spatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326]]; AGSMutablePolygon *poly = [[AGSMutablePolygon alloc] initWithSpatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326]]; [poly addRingToPolygon]; [poly addPointToRing:[AGSPoint pointWithX:x-0.0005 y:y-0.0005 spatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326]]]; [poly addPointToRing:[AGSPoint pointWithX:x+0.0005 y:y-0.0005 spatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326]]]; [poly addPointToRing:[AGSPoint pointWithX:x+0.0005 y:y+0.0005 spatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326]]]; [poly addPointToRing:[AGSPoint pointWithX:x-0.0005 y:y+0.0005 spatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326]]]; [poly closePolygon]; AGSGraphic *tempBarrier = [AGSGraphic graphicWithGeometry:poly symbol:symbol attributes:nil infoTemplateDelegate:self]; tempBarrier.attributes = attributes; [incidents_barriers addGraphic:tempBarrier]; [barrierGraphics addObject:tempBarrier]; [incidents_barriers dataChanged]; } [params setPolygonBarriersWithFeatures:barrierGraphics]; params.ignoreInvalidLocations = YES; [task solveWithParameters:params];