Loading sublayer of mapserver layer

2478
5
12-10-2015 07:09 AM
KPearson
New Contributor

I have a dynamicmapservice layer that I’m trying to load only one sublayer but the entire layer displays

The mapserver layers are the following:

Layer 1 (0)

                Sublayer1 (1)

                Sublayer2 (2)

Layer2(3)

                Sublayer1(4)

                Sublayer2(5)

My code:

var myLayer = new ArcGISDynamicMapServiceLayer("http…..", {

                id: "myLayer"

            });

            myLayer.setVisibleLayers([5]);

All of the sublayers under Layer2(3) load which is Sublayer1(4) & Sublayer(5).  I’ve tried using imageparameters but it doesn’t change anything.

var myImagePara = new ImageParameters();

myImagePara.layerIds = [5];

myImagePara.layerOption = ImageParameters.LAYER_OPTION_SHOW;

var myLayer = new ArcGISDynamicMapServiceLayer("http…..", {

                id: "myLayer",

                imageParameters: myImagePara

            });

            myLayer.setVisibleLayers([5]);

Any advice?

0 Kudos
5 Replies
KenBuja
MVP Esteemed Contributor

Things can get a little weird when using sublayers. Try setting the group layer as well as the sublayer visible at the same time.

myLayer.setVisibleLayers([3, 5]);

KPearson
New Contributor

That does the same thing which loads all the sublayers and I only want the one.

0 Kudos
KenBuja
MVP Esteemed Contributor

Here's an example that shows just one sublayer within a group.

JS Bin - Collaborative JavaScript Debugging

I'm using a service with the following structure. If you use a group layer in setVisibleLayers, then all the sublayers will be visible.

layers.png

0 Kudos
KPearson
New Contributor

Unfortunately I'm doing the same thing and it pulls in all sublayers in the group it is contained in.  Very odd.

0 Kudos
KenBuja
MVP Esteemed Contributor

Can you post the service you're having an issue with?

0 Kudos