Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

My ArcGIS JavaScript application is using an ArcGIS Server Map Service that has a bunch of layers. It also has a group layer. The structure is:

Service
    group_layer_0
        layer_1
        layer_2
    layer_3
    layer_4

After the service being loaded, it not only loads group_layer_0 (which shows layer_1 & layer_2), but also loads layer_1 and layer_2 as individual layers. In other words, layer_1 (or layer_2) is loaded twice. When I turned off group_layer_0, layer_1 is still visible because of the visibility of individual layer_1.

how should I do to avoid this? which means, when I turned off group_layer_0, it would turn off all its sub_layers; but when i turned off layer_1, it would only affect layer_1; besides, layer_1 should be loaded once, instead in current case being loaded as part of group layer and also as an individual layer.

I hope I explained this clearly. and thanks for any help!

Update:

e.g.,:

If want to turn off layer_1, i did:

var visibleLayers = mapServiceLayer.visibleLayers;
var newVisibleLayers = removeLayerIDFromLayerList(visibleLayers, 1); 
//remove layer_1's layer ID from current visibleLayers; 
//removeLayerIDFromLayerList is a developer-defined function

mapServiceLayer.setVisibleLayers(newVisibleLayers);
//update visible layers based on new list

In the above example, I turned off layer_1, but the new visible layer list still include group_layer_0, since there is no manipulation on this group layer's visibility. and the outcome is layer_1 is still visible. which doesn't make any sense. layer_1 should be off, even though it's part of a group layer.

but this is not the case, at least in my application.

share|improve this question
    
You could try to adjust the settings for display by scale for the group layer, as well as the display by scale for the individual layer. –  JLP Wisc. Jan 7 '13 at 16:50
    
thanks for your help, @JLP Wisc. I added more to the question. hope that makes it easier to understand. –  Simon Jan 7 '13 at 20:56
    
Is single fused map cache false? See answer here. –  Kirk Kuykendall Jan 9 '13 at 19:57

1 Answer 1

up vote 2 down vote accepted

The behavior of groups using the API is different than in ArcMAP TOC. This is how I understand your layerIDs:

a. LayerID0 LayerID1 LayerID2
b. LayerID1
c. LayerID2
d. LayerID3
e. LayerID4

If you turn on group layer (a), then all sublayers will be displayed.
If you turn off group layer (a) but turn on layer (b) or (c) then only layers will display.
If you turn off layers (b) or (c) and group layer (a) then none will display.

Here's an outdated but possibly relevant link to ESRI's forum topic on group layers.

Also, pardon my reiteration from my comment, but because the group layers are treated differently in the UI you could use this to your advantage by using different scale displays depending on how you are using the information in your app.

Hope this helps.

share|improve this answer
    
this explains the logic underlying group layer display. even though not 100% agree with this logic. –  Simon Jan 10 '13 at 18:24
    
yeah. we don't use groups in map services for this reason. –  JLP Wisc. Jan 10 '13 at 21:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.