Identify Task on Dynamic Map Service Layer

2413
4
Jump to solution
02-05-2014 06:53 AM
WesAskew
New Contributor II
I am using an identify task to display attributes for multiple layers within the same ArcGIS dynamic map service.  I am wondering what would be the best way of going about showing only an info window for the visible layers when clicked.  Right now, all layers appear in the info window, with an arrow which allows the user to scroll through.  This would be fine, however, the initial info window shows attributes for the top most layer whether it is visible or not.  I only want the visible layers to appear here.  I can do this with if statements, however, I would have to modify the code each time a layer is added to the map service, which I am trying to avoid.  Would I need to loop through each layer to determine the visibility, and only return results for those layers that are visible?  If so, could someone provide me with an example for a way to accomplish this without a bunch of if statements?  I have tried using the LAYER_OPTION_VISIBLE parameter, however, it does not return find any layers.  Thanks in advance.
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
Have you tried setting the layerIds property of the IdentifyParameters?

var idParams = new IdentifyParameters(); idParams.width = map.width; idParams.height = map.height; idParams.geometry = evt.mapPoint; idParams.mapExtent = map.extent; idParams.layerOption = IdentifyParameters.LAYER_OPTION_VISIBLE; idParams.layerIds = layer.visibleLayers; idParams.tolerance = 3; idParams.returnGeometry = true; idParams.spatialReference = map.spatialReference;

View solution in original post

0 Kudos
4 Replies
KenBuja
MVP Esteemed Contributor
Have you tried setting the layerIds property of the IdentifyParameters?

var idParams = new IdentifyParameters(); idParams.width = map.width; idParams.height = map.height; idParams.geometry = evt.mapPoint; idParams.mapExtent = map.extent; idParams.layerOption = IdentifyParameters.LAYER_OPTION_VISIBLE; idParams.layerIds = layer.visibleLayers; idParams.tolerance = 3; idParams.returnGeometry = true; idParams.spatialReference = map.spatialReference;
0 Kudos
WesAskew
New Contributor II
Have you tried setting the layerIds property of the IdentifyParameters?

var idParams = new IdentifyParameters();
idParams.width = map.width;
idParams.height = map.height;
idParams.geometry = evt.mapPoint;
idParams.mapExtent = map.extent;
idParams.layerOption = IdentifyParameters.LAYER_OPTION_VISIBLE;
idParams.layerIds = layer.visibleLayers;
idParams.tolerance = 3;
idParams.returnGeometry = true;
idParams.spatialReference = map.spatialReference;


Thanks for the response.  Yes, i have set the layerIds property to the visible layers.  For some reason when I when change the layerOption to LAYER_OPTION_VISIBLE, I get "No Information Available" in the info window.  Do you know what could be causing this?
0 Kudos
KenBuja
MVP Esteemed Contributor
Can you put this in JSBin to show the problem?
0 Kudos
OttarViken_Valvåg
New Contributor III
From the REST API documentation:

Note: In the case of dynamic layers the layer list is ignored, it instead uses top or all (default) to identify the layers defined in dynamicLayers parameter.
0 Kudos