One layer visible at a time with LayerList?

1220
5
Jump to solution
05-16-2019 09:24 AM
AlexGilvarry1
New Contributor III

Is it possible to set the LayerList widget to only show one layer at a time in 4.x? 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Alex,

   See this sample. It uses a group layer to set the layers to exclusive mode.

        var demographicGroupLayer = new GroupLayer({
          title: "US Demographics",
          visible: true,
          visibilityMode: "exclusive",
          layers: [USALayer, censusLayer],
          opacity: 0.75
        });‍‍‍‍‍‍‍

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=widgets-layerl...

View solution in original post

5 Replies
RobertScheitlin__GISP
MVP Emeritus

Is this a 3.x or 4.x API question?

0 Kudos
AlexGilvarry1
New Contributor III

4.x. Sorry, updated the original question.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

   See this sample. It uses a group layer to set the layers to exclusive mode.

        var demographicGroupLayer = new GroupLayer({
          title: "US Demographics",
          visible: true,
          visibilityMode: "exclusive",
          layers: [USALayer, censusLayer],
          opacity: 0.75
        });‍‍‍‍‍‍‍

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=widgets-layerl...

AlexGilvarry1
New Contributor III

This could work! Thanks! Do you know if it's possible to default the layer group to be open so it displays all the child layers when the map loads?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

See this thread:

https://community.esri.com/thread/192285-how-to-expand-the-layerlist-in-api-43#comment-696533

Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.