Select to view content in your preferred language

LayerList widget - hide listing of sublayers if only one

420
2
Jump to solution
04-02-2024 10:47 AM
DanielScholes
Emerging Contributor

I would like to use the LayerList widget to only show the map service heading without sublayers, if there is only one layer for the service. It seems unnecessary in my interface to display the sublayer if there is only one for the service. Is there a setting in the LayerList or a code example of this. For example, on the first entry, the c0a is not necessary to display.

Thanks!

Dan

 

DanielScholes_0-1712079903483.png

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Sage_Wall
Esri Contributor

Hi @DanielScholes ,

The listMode property on MapImageLayer can be used for this purpose.  You'll just want to set it to "hide-children"

https://codepen.io/sagewall/pen/qBwpOjg

      const permitsLayer = new MapImageLayer({
        portalItem: {
          // autocasts as new PortalItem()
          id: "d7892b3c13b44391992ecd42bfa92d01"
        },
        listMode: "hide-children"
      });

View solution in original post

0 Kudos
2 Replies
Sage_Wall
Esri Contributor

Hi @DanielScholes ,

The listMode property on MapImageLayer can be used for this purpose.  You'll just want to set it to "hide-children"

https://codepen.io/sagewall/pen/qBwpOjg

      const permitsLayer = new MapImageLayer({
        portalItem: {
          // autocasts as new PortalItem()
          id: "d7892b3c13b44391992ecd42bfa92d01"
        },
        listMode: "hide-children"
      });
0 Kudos
DanielScholes
Emerging Contributor

Terrific! Thank you for pointing me to the solution!