mirror of
https://github.com/walkermatt/ol-layerswitcher.git
synced 2026-01-18 14:38:42 +00:00
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.
55 lines
1.4 KiB
JavaScript
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);
|
|
})();
|