hide certain sublayer on Layerlist widget

2291
5
04-25-2018 08:10 AM
weeyeo
by
New Contributor II

I have a Grouplayer and try to hide certain sublayer on Layerlist widget. If I use listMode(hide-children) then all the sublayes not show up all.

Can someone show me  how to do it?

Thanks.

0 Kudos
5 Replies
LizEidsness
New Contributor III

Try setting the listMode("hide") on the particular layer you want to hide, not on the group layer.

0 Kudos
KristianEkenes
Esri Regular Contributor

It sounds like you need to hide the specific sublayer. In that case, you need to get the sublayer instance and set its listMode to hide. Here's a sample app that does this. If you comment out the following code, you will see the sublayer appear in the LayerList. Leave it, and it is removed, but remains in the map.

LayerList widget - 4.7 

var walkCurrentLayer = view.map.layers.flatten(function(item){
  return item.layers || item.sublayers;
}).find(function(layer){
  return layer.title === "walkability current";
});
        
walkCurrentLayer.listMode = "hide";
jamesa
by
New Contributor III

Thanks for the sample.  I try it and still can't get the sublayer to hide at all.  See the sample code below.  Can you see anything I am missing.

Edit fiddle - JSFiddle 

Thanks.

0 Kudos
KristianEkenes
Esri Regular Contributor

It looks like listMode isn't part of the MapImageLayer sublayer API: Sublayer | API Reference | ArcGIS API for JavaScript 4.7 

I'll see what we can do to add support for this?

0 Kudos
jamesa
by
New Contributor III

Thank you very much.

0 Kudos