I have a map where i'm loading several WMS layers from different urls. I'm trying to figure out a way to turn each layer on/off by an identifier, but i can't figure out how to add a unique identifier to the layer, or source of the layer. Basically i have:
for (const entry of entries) {
const tileWMSOptions = {
url: entry.URL,
params: { LAYERS: layerNames, TILED: true },
};
const layer = new TileLayer({
source: new TileWMS(tileWMSOptions),
});
mapObj.addLayer(layer);
}
my 'entry' object has an ID that i would like to associate with this layer, so that i can do some sort of
map.getLayers();
run through them, and do something specific if the id of that layer matches what i'm looking for. I don't see any way of doing this from https://openlayers.org/en/latest/apidoc/module-ol_layer_Tile-TileLayer.html or https://openlayers.org/en/latest/apidoc/module-ol_source_TileWMS.html . Any ideas?