I am creating a web application using html, CSS and JavaScript, specifically arcgis JavaScript API. I have created a layer list so that users can turn on and turn off the specific layers they want. However, there is a untitled layer and I am not sure where it is. When I try to turn it off from the layer list nothing moves from the map which suggests there is no data to toggle on or off. I have done weeks of debugging and I am getting nowhere so I would really appreciate some help. The screenshot showing the exact issue is below.
My code for the layer list looks like this:
view.when(() => {
const layerList = new LayerList({
view: view,
visible: false,
selectionEnabled: true
});
const expand = new Expand({
view: view,
content: layerList
});
// Add widget to the top right corner of the view
view.ui.add(expand, "top-left");
});
Can you provide more detail? Maybe working codepen?
Your JS is ok. Looks like someone along the way actually created a map layer named "Untitle Layer". That being the case you can use the listItemCreatedFunction in the ListItemPanel widget to make sure that specific item is not rendered.