I have a group layer from a dynamic map service. Right now I have it set to showsubLayers: true under the layerlist function. I want to exclude one of the sublayers from this. It's a mask that I want to always be on and not be visible in the list. Is this possible?
Solved! Go to Solution.
Is there no better solution now, in 2018, perhaps using DynamicLayerInfos?
I'm trying this with no luck(attempting to remove layer 0 from the sublayers in the LayerList):
dynamicLayerInfos = [
new DynamicLayerInfo({ id: -1, subLayerIds: [1,2,3,4,5]}),
new DynamicLayerInfo({ id: 1 }),
new DynamicLayerInfo({ id: 2 }),
new DynamicLayerInfo({ id: 3 }),
new DynamicLayerInfo({ id: 4 }),
new DynamicLayerInfo({ id: 5 })
];
dynamicMapServiceLayer.setDynamicLayerInfos(dynamicLayerInfos);
Having to resort to DOM manipulation is really kind of awful.
I was trying to remove a graphic layer from the layer list in 4.8 and found this, in particular the comment from Kristian Ekenes. I slightly modified her code to my needs and it worked. Hopefully this is still relevant to you almost two months after your post.
//Hide graphic layer from layerList
var graphicCurrentLayer = view.map.layers.flatten(function(item){
return item.layers;
}).find(function(layer){
return layer.title === "Graphics Layer";
});
graphicCurrentLayer.listMode = "hide";