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?
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]);
That does the same thing which loads all the sublayers and I only want the one.
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.
Unfortunately I'm doing the same thing and it pulls in all sublayers in the group it is contained in. Very odd.
Can you post the service you're having an issue with?