Nested identifyTask works only when at max zoom level

2122
3
Jump to solution
10-14-2013 02:54 PM
JacksonTrappett
Occasional Contributor II
I have a strange issue.  I am using SDK 7.0 and 10.1.1 Update 2.  This same issue was present before I moved to 7.0, back on 6 as well however.

I have code that does an identify on a dynamic service layer.  When the results are returned, if they are empty, then it automatically does a new identify on another dynamic service layer.  This workflow is so that if there is something turned on in the top layer, the Identify will return from that layer, but if there wasn't something in that service where the user picked, then it will move down to the next layer and return results from there.

This is working just fine, but only if I'm zoomed all the way in to the map.  The original identify works no matter what my zoom level is, but the second identify only seems to work if I'm zoomed in all the way.  Also, if I pick while zoomed out, and the second identify fires, then I zoom in, the popup will show up once I zoom all the way in, and it will stay if I zoom back out.

Here's the code (I left out parts that don't seem important):
@synthesize identifyTask = _identifyTask,identifyParams=_identifyParams; @synthesize identifyTaskBase = _identifyTaskBase,identifyParamsBase=_identifyParamsBase;  - (void)viewDidLoad {     [super viewDidLoad];     self.mapView.touchDelegate = self;     self.mapView.calloutDelegate = self;     self.mapView.callout.delegate = self; ...     self.identifyTask = [AGSIdentifyTask identifyTaskWithURL:[NSURL URLWithString:@"http://****/ArcGIS/rest/services/CityMap/MapServer"]];     self.identifyTask.delegate = self;     self.identifyParams = [[AGSIdentifyParameters alloc] init];     self.identifyTaskBase = [AGSIdentifyTask identifyTaskWithURL:[NSURL URLWithString:@"http://****/arcgis/rest/services/BaseMap/GJMAP/MapServer"]];     self.identifyTaskBase.delegate = self;     self.identifyParamsBase = [[AGSIdentifyParameters alloc] init]; ... }  - (void)mapView:(AGSMapView *)mapView didClickAtPoint:(CGPoint)screen mapPoint:(AGSPoint *)mappoint graphics:(NSDictionary *)graphics {     self.mappoint = mappoint;     NSMutableArray *layerIDs = [NSMutableArray array];     for (AGSLayer *layer in self.mapView.mapLayers)     {         if([layer isKindOfClass:[AGSDynamicMapServiceLayer class]])         {             AGSDynamicMapServiceLayer *tempLayer = (AGSDynamicMapServiceLayer *)layer;             layerIDs = [tempLayer.visibleLayers mutableCopy];         }     }          self.identifyParams.layerIds = layerIDs;     self.identifyParams.tolerance = 8;     self.identifyParams.geometry = self.mappoint;     self.identifyParams.size = self.mapView.bounds.size;     self.identifyParams.mapEnvelope = self.mapView.visibleArea.envelope;     self.identifyParams.returnGeometry = YES;     self.identifyParams.layerOption = AGSIdentifyParametersLayerOptionTop;     self.identifyParams.spatialReference = self.mapView.spatialReference;      [self.identifyTask executeWithParameters:self.identifyParams]; }  - (void)identifyTask:(AGSIdentifyTask *)identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results {     [self.graphicsLayer removeAllGraphics];     if ([results count] > 0)     {         AGSSymbol* symbol = [AGSSimpleFillSymbol simpleFillSymbol];         symbol.color = [UIColor colorWithRed:0 green:0 blue:1 alpha:0.5];         for (AGSIdentifyResult* result in results)         {             result.feature.symbol = symbol;             [self.graphicsLayer addGraphic:result.feature];         }         NSString *layerName = [((AGSIdentifyResult*)[results objectAtIndex:0]) layerName];         self.mapView.callout.title = layerName;         self.mapView.callout.detail = @"Click for more detail..";         [self.mapView.callout showCalloutAtPoint:self.mappoint forGraphic:((AGSIdentifyResult*)[results objectAtIndex:0]).feature animated:YES];     }     else     {         //do another identify on base layer (parcels etc)         self.identifyParamsBase.layerIds = @[@36,@37,@38,@39];         self.identifyParamsBase.tolerance = 8;         self.identifyParamsBase.geometry = self.mappoint;         self.identifyParamsBase.size = self.mapView.bounds.size;         self.identifyParamsBase.mapEnvelope = self.mapView.visibleArea.envelope;         self.identifyParamsBase.returnGeometry = YES;         self.identifyParamsBase.layerOption = AGSIdentifyParametersLayerOptionTop;         self.identifyParamsBase.spatialReference = self.mapView.spatialReference;                 //execute the task         [self.identifyTaskBase executeWithParameters:self.identifyParamsBase];     } }  - (void)identifyTaskBase:(AGSIdentifyTask *)identifyTaskBase operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results {     [self.graphicsLayer removeAllGraphics];     if ([results count] > 0)     {         AGSSymbol* symbol = [AGSSimpleFillSymbol simpleFillSymbol];         symbol.color = [UIColor colorWithRed:0 green:0 blue:1 alpha:0.5];         for (AGSIdentifyResult* result in results)         {             result.feature.symbol = symbol;             [self.graphicsLayer addGraphic:result.feature];         }         NSString *layerName = [((AGSIdentifyResult*)[results objectAtIndex:0]) layerName];         self.mapView.callout.title = layerName;         self.mapView.callout.detail = @"Click for more detail..";         [self.mapView.callout showCalloutAtPoint:self.mappoint forGraphic:((AGSIdentifyResult*)[results objectAtIndex:0]).feature animated:YES];     } }


Does anyone see anything directly wrong with this code?  What is baffling me is that it works fine if I am zoomed all the way in, but doesn't display properly otherwise.  Also the fact that if there is a layer turned on for the first identify to hit, that works at any zoom level, and it is set up the exact same way.

Thanks for any tips or help!
Jackson
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
Try changing the identify parameter's layerOption to AGSIdentifyParametersLayerOptionVisible.

Regards,
Nimesh

View solution in original post

0 Kudos
3 Replies
NimeshJarecha
Esri Regular Contributor
Try changing the identify parameter's layerOption to AGSIdentifyParametersLayerOptionVisible.

Regards,
Nimesh

View solution in original post

0 Kudos
JacksonTrappett
Occasional Contributor II
Try changing the identify parameter's layerOption to AGSIdentifyParametersLayerOptionVisible.

Regards,
Nimesh


Thanks for the reply!  I gave that a try, switched one, and then both of them to AGSIdentifyParametersLayerOptionVisible, but it didn't make any difference in my results.  The first identify always works at any zoom level as long as I pick on a layer that is on.  The second only works if I am zoomed all the way in OR only shows up after I zoom all the way in.

I also tried changing the second identify task to AGSIdentifyParametersLayerOptionAll, which seemed to fix the problem.  I will do some more testing to verify this, but I think that will work with my workflow.

Thanks,
Jackson
0 Kudos
NimeshJarecha
Esri Regular Contributor
Good to know that AGSIdentifyParametersLayerOptionAll works for you. Based on result, I assume that when you are zoomed out, the layers which are not working probably not visible.

Regards,
Nimesh
0 Kudos