Reordering of dynamic layers with groups (parents and sublayers).

832
1
10-24-2012 04:25 AM
ViktorLozhkin
New Contributor
Hello.
I need to reorder layers in the instance of esri.layers.ArcGISDynamicMapServiceLayer. I saw this sample for learning.

Also, I have two map services with enabled Dynamic Layer option. First service contains a plain list of layers, and the second contains grouped layers (parents and sublayers). Reordering on the first service works fine, but on the second service layers becomes invisible after reordering (both layers has a same parent).

Are there some restrictions on layers reordering, when layers are in groups? Thank you.
0 Kudos
1 Reply
JakubMalec
New Contributor III
Hi,

I'm also having some trouble with implementing grouped layers reordering in my JS app.

So far I've succeded in reordering layers inside a group, which is a piece of cake, and is as simple as the example:
/* ------------------------------------------------------------------------------------*/
// Let's assume that we have a dynamic layer with id "dynamicLayerId" on the map
// and the sublayer of "dynamicLayerId" with id 0 is the parent of sublayers with ids 1 and 2
//
// This code will swap sublayers 1 and 2 and display them on the map
/* ------------------------------------------------------------------------------------*/

var layer = map.getLayer("dynamicLayerId");
var dynamicLayerInfos = layer.createDynamicLayerInfosFromLayerInfos();

// changing the order
dynamicLayerInfos[1].id = 2;
dynamicLayerInfos[2].id = 1;

// updating the dynamic infos of the layer
layer.setDynamicLayerInfos(dynamicLayerInfos);

// display the sublayers on the map
layer.setVisibleLayers(["1", "2"]);


What I'm having trouble with is reordering the whole groups. The picture shows what happens inside dynamicLayerInfos when someone tries to reorder the groups in my app:
[ATTACH=CONFIG]26695[/ATTACH]
After updating the dynamicLayerInfos of the layer, no sublayer is shown on the map (when there are some visibleLayers set). So my question is: Am I doing something wrong here?
Also I would really appreciate if someone, who has done it, could share some code ;]


PS. It's an old topic, I know, but it'd be bad to leave it without some useful answers;]


EDIT: FINALLY!
Writing this post and reading it made me realise that I didn't update parentLayerId properties of the group members. I fixed that and the problem is gone - everything works fine :D.
0 Kudos