I'm building an app with the ArcGIS JavaScript API, version 3.16. I have a map with two feature layers and I'd like to use the LayerList widget so the user can toggle them on and off. It's functional as I have it written, but not ideal in a couple of ways. The layers appear in the layer list as "graphicsLayer1" and "graphicsLayer2", and I'd like to find a way to give them more descriptive names. Also, the layers are visible when the box is unchecked, and become invisible when I check the box, and I'd like to flip that around.
The relevant section of code is below.
var mapMain = new Map("mapDiv", {
basemap: "topo",
center: [-120, 38],
zoom: 6
});
var resLyrLn = new FeatureLayer("https://data.farwestern.com/arcgis/rest/services/scratch/test_SD_RelatedResources/MapServer/0", {
mode: FeatureLayer.MODE_ONDEMAND,
visible: true,
});
var resLyrArea = new FeatureLayer("https://data.farwestern.com/arcgis/rest/services/scratch/test_SD_RelatedResources/MapServer/1", {
mode: FeatureLayer.MODE_ONDEMAND,
visible: true,
});
var lyrs = [resLyrArea, resLyrLn]
mapMain.addLayers(lyrs);
var layerListDijit = new LayerList({
map: mapMain,
layers: lyrs
}, "layersDiv");
layerListDijit.startup();