-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
125 lines (113 loc) · 3.8 KB
/
index.html
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
119
120
121
122
123
124
125
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Informação Geográfica e Visualização</title>
<link rel="stylesheet" href="libraries/ol.css" type="text/css">
<script src="libraries/ol.js"></script>
</head>
<body>
<div id="map" class="map"></div>
<select id="layer-select">
<option value="Aerial" selected>Bing (aéreo)</option>
<!--<option value="AerialWithLabels">Bing (áereo) (com etiquetas)</option>
<option value="Road">Bing Estrada (estático)</option>
<option value="RoadOnDemand">Bing Estrada (dinâmico)</option>-->
<option value="OSM">OSM</option>
</select>
<input id="checkBoxLayerPolygon" type="checkbox" checked="true" style="margin-left: 20px;"/>
<label for="checkBoxLayerPolygon" style="font-family: Arial; font-size: 13.3333px; padding-right: 20px;">Concelho do Porto</label>
<input id="checkBoxLayerLine" type="checkbox" checked="true"/>
<label for="checkBoxLayerLine" style="font-family: Arial; font-size: 13.3333px; padding-right: 20px;">Rede Viária</label>
<input id="checkBoxLayerPoint" type="checkbox" checked="true"/>
<label for="checkBoxLayerPoint" style="font-family: Arial; font-size: 13.3333px; padding-right: 20px;">Pontos de Interesse</label>
</div>
<script>
var styles = [
'Road',
'RoadOnDemand',
'Aerial',
'AerialWithLabels',
'OSM'
];
var layers = [];
var i, ii;
for (i = 0, ii = styles.length - 1; i < ii; ++i) {
layers.push(new ol.layer.Tile({
visible: false,
preload: Infinity,
source: new ol.source.BingMaps({
key: 'AqpkOitxbnh_CJ3NT5suGaaEPYsCwl3LByiJIMjNDCa2tTN-ZxmpTOKfUk7CjBoK',
imagerySet: styles[i]
})
}));
}
layers.push(new ol.layer.Tile({
visible: false,
preload: Infinity,
source: new ol.source.OSM()
}));
layers.push(new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://localhost:8080/geoserver/wms',
params: {
'LAYERS': 'BGRI:bgri11_cont_conc_porto_unified',
'TILED': true
},
serverType: 'geoserver',
projection: 3763
})
}));
layers.push(new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://localhost:8080/geoserver/wms',
params: {
'LAYERS': 'BGRI:rede_viaria_conc_porto',
'TILED': true
},
serverType: 'geoserver',
projection: 3763
})
}));
layers.push(new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://localhost:8080/geoserver/wms',
params: {
'LAYERS': 'BGRI:points_conc_porto',
'TILED': true
},
serverType: 'geoserver',
projection: 3763
})
}));
var map = new ol.Map({
layers: layers,
loadTilesWhileInteracting: true,
target: 'map',
view: new ol.View({
//WebMercator 3857
center: [-963679.81, 5033492.99],
zoom: 11
})
});
var select = document.getElementById('layer-select');
var checkbox_polygon = document.getElementById('checkBoxLayerPolygon');
var checkbox_line = document.getElementById('checkBoxLayerLine');
var checkbox_point = document.getElementById('checkBoxLayerPoint');
function onChange() {
var style = select.value;
for (var i = 0, ii = layers.length; i < ii; ++i) {
layers[i].setVisible(styles[i] === style);
layers[layers.length - 3].setVisible(checkbox_polygon.checked);
layers[layers.length - 2].setVisible(checkbox_line.checked);
layers[layers.length - 1].setVisible(checkbox_point.checked);
}
};
select.addEventListener('change', onChange);
checkbox_polygon.addEventListener('change', onChange);
checkbox_line.addEventListener('change', onChange);
checkbox_point.addEventListener('change', onChange);
onChange();
</script>
</body>
</html>