Robert,
I am not sure how I would check the visible property for each service. I ended up creating a duplicate feature layer of the services I am using (Zone1) and hide from my layerlist and set it to show in legend, so a user would not be able to toggle it off or on. But they funny the thing is that layer can never be turned off now, since it is hidden. Is there a way to always show a feature layer in the legend even though the the visible property is false
Steve, I tried your suggestion below, but couldn't get it to work. Even though all my layers are turned off, I still have the hidden layer visible on map
//Add the legend
var legend = new Legend({
view: view,
container: document.createElement("div")
//this shows one legend instead of all 8 zones
,layerInfos: [{
layer: HiddenZoneLayer, // name of layer to display always
title: "My Legend"
}]
//end showing one
});
var lgExpand = new Expand({
view: view,
content: legend.domNode,
expandIconClass: "esri-icon-layer-list",
expanded: true,
expandTooltip: "Expand Legend", // optional, defaults to "Expand" for English locale
});
// Add the widget to the bottom left corner of the view
view.ui.add(lgExpand, "bottom-right");
// view.ui.add(legend, "bottom-right");