I am trying to create a map with multiple layers which I can setvisible false or true. This is my code to set up the map:
this.map = new OlMap({
target: 'map',
layers: [
new OlTileLayer({
source: new OSM()
}), new Group({
layers: [
new OlTileLayer({
source: new TileJSON({
url: 'https://api.tiles.mapbox.com/v3/mapbox.20110804-hoa-foodinsecurity-3month.json?secure',
crossOrigin: 'anonymous'
})
}),
new OlTileLayer({
source: new TileJSON({
url: 'https://api.tiles.mapbox.com/v3/mapbox.world-borders-light.json?secure',
crossOrigin: 'anonymous'
})
})
]
})
],
view: this.view
});
It works fine I can see the map and all the Layers. With a checkbox I want to set a certain layer to false or true.
How can i get the id of every layer that I have added and how can I set the visibility to false. I am using openlayers4 with Angular5
Thx a lot!