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
2014 - September Ridership
Ex. 2
2015 - March Weekdays
2015 - March Saturdays
2015 - March Sundays
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();
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" );
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
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.
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(