-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckbox.js
118 lines (103 loc) · 3.13 KB
/
checkbox.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
import LayerGroup from 'ol/layer/Group';
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer';
import TileWMS from 'ol/source/TileWMS';
import {Map, View} from 'ol';
import OSM from 'ol/source/OSM';
import map from './index.js';
var layersRoads = new LayerGroup({
layers: [
new TileLayer({
source: new TileWMS({
url: 'http://localhost:8080/geoserver/geo_test1/wms',
params: {'LAYERS': ' geo_test1:gis_osm_roads_free_1', 'TILED': true},
serverType: 'geoserver',
transition: 0,
})
}) ]
});
var layersTransport = new LayerGroup({
name: 'PublicTransportLayer',
layers: [
new TileLayer({
source: new TileWMS({
url: 'http://localhost:8080/geoserver/geo_test1/wms',
params: {'LAYERS': 'geo_test1:gis_osm_transport_free_1', 'TILED': true},
serverType: 'geoserver',
transition: 0,
})
}) ]
});
var layersPlaces = new LayerGroup({
name: 'PlacesLayer',
layers: [
new TileLayer({
source: new TileWMS({
url: 'http://localhost:8080/geoserver/geo_test1/wms',
params: {'LAYERS': 'geo_test1:gis_osm_places_free_1', 'TILED': true},
serverType: 'geoserver',
transition: 0,
})
}) ]
});
var layersPois = new LayerGroup({
name: 'PointofInterestsLayer',
layers: [
new TileLayer({
source: new TileWMS({
url: 'http://localhost:8080/geoserver/geo_test1/wms',
params: {'LAYERS': 'geo_test1:gis_osm_pois_free_1', 'TILED': true},
serverType: 'geoserver',
transition: 0
})
}) ]
});
var transportCheckbox = document.querySelector("input[name=transportCheck]");
var roadsCheckbox = document.querySelector("input[name=roadsCheck]");
var placesCheckbox = document.querySelector("input[name=placesCheck]");
var poisCheckbox = document.querySelector("input[name=poisCheck]");
transportCheckbox.addEventListener( 'change', function() {
if(this.checked) {
// Checkbox is checked..
console.log("checked");
map.addLayer(layersTransport);
} else {
// Checkbox is not checked..
console.log("not checked");
map.removeLayer(layersTransport);
}
});
roadsCheckbox.addEventListener( 'change', function() {
if(this.checked) {
// Checkbox is checked..
console.log("checked");
map.addLayer(layersRoads);
} else {
// Checkbox is not checked..
console.log("not checked");
map.removeLayer(layersRoads);
}
});
placesCheckbox.addEventListener( 'change', function() {
if(this.checked) {
// Checkbox is checked..
console.log("checked");
map.addLayer(layersPlaces);
} else {
// Checkbox is not checked..
console.log("not checked");
map.removeLayer(layersPlaces);
}
});
poisCheckbox.addEventListener( 'change', function() {
if(this.checked) {
// Checkbox is checked..
console.log("checked");
map.addLayer(layersPois);
} else {
// Checkbox is not checked..
console.log("not checked");
map.removeLayer(layersPois);
}
});
*/