esri/dijit/LayerList Question

3387
3
07-30-2015 04:03 PM
JohnRitsko
New Contributor III

Here is what I'm trying to do with the Layer List.

I have layers in my mxd that have sublayers upon sublayers.  Here is an example shown below my question.  So in my mxd I have a group layer, 2015 - March Ridership, which then has a sublayer (Weekdays, Saturdays, Sundays), all of which have another sublayer (Ons, Offs).  Is there a way to utilize the layerList to do this?  If not, how can I set it up to simply show one sublayer (see Ex. 2)?  I have tried and tried with no luck.

Ex. 1

2015 - March Ridership

  • Weekdays
    1. Ons
    2. Offs
  • Saturdays
    1. Ons
    2. Offs
  • Sundays
    1. Ons
    2. Offs

2014 - September Ridership

  • Weekdays
    1. Ons
    2. Offs
  • Saturdays
    1. Ons
    2. Offs
  • Sundays
    1. Ons
    2. Offs

 

Ex. 2

2015 - March Weekdays

  1. Ons
  2. Off

2015 - March Saturdays

  1. Ons
  2. Offs

2015 - March Sundays

  1. Ons
  2. Offs

Currently my widget looks like this as I can't seem to get the sublayer: true working:

      var ridershipWidget = new LayerList(

          {

              map: map,

              layers: [

                {

                    layer:mar15SaturdaysOff

                }, {

                    layer:mar15SaturdaysOn

                }, {

                    layer:mar15WeekdaysOff

                },{

                    layer:mar15WeekdaysOn

                }

              ]

          }, "ridershipList"

      );

     

    
ridershipWidget.startup();

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

John,

    Maybe it was just a typo, but you meant sublayers (plural with an s right).

      var ridershipWidget = new LayerList(
          {
              map: map,
              layers: [
                { 
                    layer:mar15SaturdaysOff
                }, {
                    layer:mar15SaturdaysOn
                }, { 
                    layer:mar15WeekdaysOff
                },{ 
                    layer:mar15WeekdaysOn
                }
              ],
              sublayers: true
          }, "ridershipList"
      );
0 Kudos
JohnRitsko
New Contributor III

Robert,

  So here is what I'm working with below.  If I add say layer (1, 2) and then add the "sublayers: true" statement where you show it above it doesn't show up like I want it to, or how I imagine it to.  I simply shows Layer 1, Layer 2 which can be toggled on or off.  I want to show it as such:

2015 March Weekdays

  • Weekdays On
  • Weekdays Off

  I have tried adding layer 0 and then saying sublayers: true and that doesn't work out for me either.

Thanks for taking the time to help me out.

Ridership.png

0 Kudos
LoriEmerson_McCormack
Occasional Contributor

Hi John,

     Set the showSubLayers to true for each layer within the layers: [ ] statement.  I added the extra showLegend just to illustrate that you can add additional options here for each layer.  You don't need the showSubLayers statement outside of the layers: [ ] statement which is why I deleted it.

 

   var ridershipWidget = new LayerList( 

  •           { 
  •               map: map, 
  •               layers: [ 
  •                 {  
  •                     layer:mar15SaturdaysOff 
        • , showSubLayers: true
        • , showLegend: false
  •                 }, { 
  •                     layer:mar15SaturdaysOn 
        • , showSubLayers: true
        • , showLegend: false
  •                 }, {  
  •                     layer:mar15WeekdaysOff 
        • , showSubLayers: true
        • , showLegend: false
  •                 }, {  
  •                     layer:mar15WeekdaysOn 
        • , showSubLayers: true
        • , showLegend: false
  •                 } 
  •               ]
  •           }, "ridershipList" 
  •       ); 
0 Kudos