I have configured a WMS layer for OpenLayers like:
var wmsSource = new ol.source.ImageWMS({
url: 'http://<servername>/geoserver/<namespace>/wms',
params: {'LAYERS': [ 'Layer 001', 'Layer 002', ... 'Layer xxx' ]},
ratio: 1.2,
serverType: 'geoserver'
})
var wms = new ol.layer.Image({
title: 'Basemap',
type: 'base',
source: wmsSource
})
The layer-switch I use is this one: https://github.com/walkermatt/ol3-layerswitcher
It is configured like
var layerSwitcher = new ol.control.LayerSwitcher({
tipLabel: 'Legend'
});
map.addControl(layerSwitcher);
Now the layer-switcher only shows one "Basemap" entry. But I want to have the WMS-Layers listed – best in a group "Basemap".
Any ideas how to do this?
Best Answer
Totally agree with Revo. You can use ol.layer.Group for defining multiple base layers and / or overlays.
You can define Base layers like bl1, bl2, bl3 ... etc and put them together in a Group say baselayers in the following manner.
Similarly you can define overlays say ol1, ol2, ol3 ... etc and put them into a Group say overlays as follows:
Now you can define the map element and put these baselayers and overlays into it.
You need to add ol3-layerswitcher.js javascript in your head section of html page.