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.
Thank you very much.
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?
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
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
<SPAN class="keyword token">var</SPAN> walkCurrentLayer <SPAN class="operator token">=</SPAN> view<SPAN class="punctuation token">.</SPAN>map<SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">.</SPAN><SPAN class="token function">flatten</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> item<SPAN class="punctuation token">.</SPAN>layers <SPAN class="operator token">||</SPAN> item<SPAN class="punctuation token">.</SPAN>sublayers<SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">find</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> layer<SPAN class="punctuation token">.</SPAN>title <SPAN class="operator token">===</SPAN> <SPAN class="string token">"walkability current"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> walkCurrentLayer<SPAN class="punctuation token">.</SPAN>listMode <SPAN class="operator token">=</SPAN> <SPAN class="string token">"hide"</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Try setting the listMode("hide") on the particular layer you want to hide, not on the group layer.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.