-
Notifications
You must be signed in to change notification settings - Fork 4
/
setstyle.html
73 lines (67 loc) · 2.39 KB
/
setstyle.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='./node_modules/mapbox-gl/dist/mapbox-gl.js'></script>
<link href='./node_modules/mapbox-gl/dist/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<style>
#menu {
position: absolute;
background: #fff;
padding: 10px;
font-family: 'Open Sans', sans-serif;
}
</style>
<div id='map'></div>
<div id='menu'>
<input id='ktbasic' type='radio' name='rtoggle' value='ktbasic' checked='checked'>
<label for='ktbasic'>basic (klokantech)</label>
<input id='osmliberty' type='radio' name='rtoggle' value='osmliberty'>
<label for='osmliberty'>OSM liberty</label>
<input id='osmbright' type='radio' name='rtoggle' value='osmbright'>
<label for='osmbright'>OSM bright</label>
<input id='positron' type='radio' name='rtoggle' value='positron'>
<label for='positron'>positron</label>
<input id='positroncolor' type='radio' name='rtoggle' value='positroncolor'>
<label for='positroncolor'>positroncolor</label>
<input id='darkmatter' type='radio' name='rtoggle' value='darkmatter'>
<label for='darkmatter'>dark matter</label>
<input id='dark' type='radio' name='rtoggle' value='dark'>
<label for='dark'>dark</label>
<input id='klokantech3d' type='radio' name='rtoggle' value='klokantech3d'>
<label for='klokantech3d'>klokantech 3D</label>
<input id='pdoklufo' type='radio' name='rtoggle' value='pdoklufo'>
<label for='pdoklufo'>PDOK luchtfoto</label>
</div>
<script>
//mapboxgl.accessToken = '<your access token here>';
var map = new mapboxgl.Map({
container: 'map',
zoom: 13,
style: 'styles/openmaptiles/ktbasic.json',
center: [4.913196, 52.342259]
});
var layerList = document.getElementById('menu');
var inputs = layerList.getElementsByTagName('input');
function switchLayer(event) {
var layerId = event.target.id;
if (layerId != 'pdoklufo') {
map.setStyle('styles/openmaptiles/' + layerId + '.json');
} else {
map.setStyle('styles/' + layerId + '.json');
}
}
for (var i = 0; i < inputs.length; i++) {
inputs[i].onclick = switchLayer;
}
</script>
</body>
</html>