forked from walkermatt/ol-layerswitcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
layerswitcher.js
55 lines (53 loc) · 1.84 KB
/
layerswitcher.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(function() {
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Group({
'title': 'Base maps',
layers: [
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()
}),
new ol.layer.Tile({
title: 'Satellite',
type: 'base',
visible: false,
source: new ol.source.MapQuest({layer: 'sat'})
})
]
}),
new ol.layer.Group({
title: 'Overlays',
layers: [
new ol.layer.Tile({
title: 'Countries',
source: new ol.source.TileWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
params: {'LAYERS': 'ne:ne_10m_admin_1_states_provinces_lines_shp'},
serverType: 'geoserver'
})
})
]
})
],
view: new ol.View({
center: ol.proj.transform([-0.92, 52.96], 'EPSG:4326', 'EPSG:3857'),
zoom: 6
})
});
var layerSwitcher = new ol.control.LayerSwitcher({
tipLabel: 'Légende' // Optional label for button
});
map.addControl(layerSwitcher);
})();