ol-layerswitcher/examples/collapse-groups.js
Matt Walker 5480f926f8 Update examples to use current data and updated ol-sidebar
The OSN boundary data appears to no longer be available so it's been
replaced with some USA sample data thanks to ESRI.

The sidebar component (https://github.com/Turbo87/sidebar-v2) isn't
currently compatible with OpenLayers 7 due to the JS being an ES5
prototype based class, an updated ES6 class version is now bundled
included in the examples directory.
2023-03-08 11:02:16 +00:00

55 lines
1.4 KiB
JavaScript

(function () {
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Group({
title: 'Base maps',
fold: 'open',
layers: [
new ol.layer.Group({
title: 'Water color with labels',
type: 'base',
combine: true,
visible: false,
layers: [
new ol.layer.Tile({
source: new ol.source.Stamen({
layer: 'watercolor'
})
}),
new ol.layer.Tile({
source: new ol.source.Stamen({
layer: 'terrain-labels'
})
})
]
}),
new ol.layer.Tile({
title: 'Water color',
type: 'base',
visible: false,
source: new ol.source.Stamen({
layer: 'watercolor'
})
}),
new ol.layer.Tile({
title: 'OSM',
type: 'base',
visible: true,
source: new ol.source.OSM()
})
]
})
],
view: new ol.View({
center: ol.proj.transform([-80.789, 37.926], 'EPSG:4326', 'EPSG:3857'),
zoom: 5
})
});
var layerSwitcher = new ol.control.LayerSwitcher({
tipLabel: 'Légende' // Optional label for button
});
map.addControl(layerSwitcher);
})();