@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]; } }
Solved! Go to Solution.
Try changing the identify parameter's layerOption to AGSIdentifyParametersLayerOptionVisible.
Regards,
Nimesh