Select to view content in your preferred language

BUG? .visibleLayers returns group layeys

1175
3
10-11-2012 05:52 AM
AdrianMarsden
Honored Contributor
Hi

I *think* this may be a bug, but please be kind if it isn't.

I have a Map Service with sublayers in groups - defined in the ArcMap MXD.

Because

IdentifyParameters.LAYER_OPTION_VISIBLE doesn't work

I use

 identifyParams.layerIds = dynamicMapServiceLayer.visibleLayers;


However the first time this is run, the array returned by dynamicMapServiceLayer.visibleLayers contains group0 layer IDs - this causes the ID task to return very odd results.  Several results are repeated (I've check the JSON in Fiddler and this is in the actual returned data, not a code glitch on my side)

After a layer has been switched on (or off) the returned array by dynamicMapServiceLayer.visibleLayers returns just the real sublayers - not the group Ids and the Id task works fine

Alas, this is an internal service so I can't provide the links
0 Kudos
3 Replies
__Rich_
Deactivated User
The granularity of visibility in ArcMap applies to branch (group) and leaf nodes in the layer hierarchy; both variations of node are of type layer, so to me it makes sense that visibleLayers contains both group layers and 'leaf' layers.

Try calling Identify without setting the layerIds property - still see duplicates?
0 Kudos
AdrianMarsden
Honored Contributor
Without setting layerIds works fine, but then it doesn't honour the visible layers.

I agree, it makes sense that you get the group IDs back, what doesn't make sense is that after you make a change from the default visibility , the dynamiclayer.visibleLayers returns an array without these in, which is what I want, but if i knew it ALWAYS returned the group Ids I could code them out until LAYER_OPTION_VISIBLE is fixed.

Cheers

ACM
0 Kudos
AdrianMarsden
Honored Contributor
For info, whilst I still think this is a potential bug, until LAYER_OPTION_VISIBLE is fixed, I'm calling my own function to get visible layers excluding group layers - especially as I agree dynamicMapServiceLayer.visibleLayers should return all layers, including group ones, so if it is a bug, it works to start with then breaks, but currently breaks in my favour.

function getVisibleLayers() {    var visibleLayers = [];
    var items = dojo.map(dynamicMapServiceLayer.layerInfos, function (info, index) {
        layerID = info.id;
        if (info.visible && !info.subLayerIds) {
            visibleLayers.push(layerID)
        }
    }); return visibleLayers
}


ACM
0 Kudos