Hi All,
I've got a working webmap (JS 4.24), using an AGOL web map but I can't figure out how to access the individual layers contained in the webmap. I just want to be able to reference a specific layer so I can do things like toggle it's visibility.
I've tried a couple of methods (see below), but if they are working I haven't been able to find a way to then reference the layer (where do I put the visible: true, statement? Or the listMode: 'hide' statement?
Obviously I'm fairly new to JavaScript...
Is there a better way to reference a layer in a webmap?
Having referenced it, how do I set it's properties?
Any advice or suggestions appreciated,
thanks,
~stefan
Stuff I've tried:
const webmap = new WebMap({
portalItem: {
id: "9c161033f604436193805a7484feab3d" // Web Map for JavaScript
}
});
const view = new MapView({
container: "viewDiv",
map: webmap,
});
// get layers when the view is initialized
webmap.when(() => {
// layer 0
const layer0 = webmap.layers.items[0];
});
// OR Find a layer by ID...
const layer1 = webmap.findLayerById("958f6534812a4407925a2a18a640b841");