-
Notifications
You must be signed in to change notification settings - Fork 1
/
route66.html
116 lines (97 loc) · 2.95 KB
/
route66.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>route 66 demo</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.0/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 {
background: #fff;
position: absolute;
z-index: 1;
top: 10px;
right: 10px;
border-radius: 3px;
width: 120px;
border: 1px solid rgba(25,85,163,0.5);
font-family: 'Open Sans', sans-serif;
}
#menu a {
font-size: 10px;
color: #1955a3;
display: block;
margin: 0;
padding: 0;
padding: 8px;
text-decoration: none;
border-bottom: 1px solid rgba(25,85,163,0.5);
text-align: center;
}
#menu a:last-child {
border: none;
}
#menu a:hover {
background-color: #f8f8f8;
color: #404040;
}
#menu a.active {
background-color: #c6dbf6;
color: #1955a3;
}
#menu a.active:hover {
background: #c4c4c4;
}
</style>
<nav id="menu"></nav>
<div id="map"></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoiaGFrdXNwb3J0cyIsImEiOiJjam0yZzZzb2cwM2xiM3ZtbWlhMHFiZ2V3In0.q9MAwyAZiww1MsOQx3GUPw';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/hakusports/ck30pbxts02by1cqcd5crpgrr/draft',
zoom: 12.5,
center: [-95.970,36.1374]
});
var toggleableLayerIds = [ 'Marathon Course',
'Half Marathon Course',
'Marathon Timing Points',
'Half Marathon Timing Points',
'Marathon Mile Markers',
'Half Marathon Mile Markers',
'Relay Locations',
'Gatorade Stations',
'Medical Tents'
];
for (var i = 0; i < toggleableLayerIds.length; i++) {
var id = toggleableLayerIds[i];
var link = document.createElement('a');
link.href = '#';
link.className = '';
link.textContent = id;
link.onclick = function (e) {
var clickedLayer = this.textContent;
e.preventDefault();
e.stopPropagation();
var visibility = map.getLayoutProperty(clickedLayer, 'visibility');
if (visibility === 'visible') {
map.setLayoutProperty(clickedLayer, 'visibility', 'none');
this.className = '';
} else {
this.className = 'active';
map.setLayoutProperty(clickedLayer, 'visibility', 'visible');
}
};
var layers = document.getElementById('menu');
layers.appendChild(link);
}
</script>
</body>
</html>