-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
118 lines (108 loc) · 3.61 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Walk 2022</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no'/>
<script src='./polyline.js'></script>
<script src="https://psedge-strava.s3.eu-north-1.amazonaws.com/data-2.js"></script>
<script src='https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.css' rel='stylesheet'/>
<style>
body {
margin: 0;
padding: 0;
font-family: Roboto, sans-serif;
overflow-x: hidden;
width: 100%
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
#title {
position: absolute;
top: 10px;
right: 20px;
height: 10%;
background: transparent;
color: #fafafa;
min-width: 200px;
}
#info {
position: absolute;
top: 10px;
left: 20px;
height: 75%;
width: 45%;
background: transparent;
color: #fafafa;
max-width: 200px;
}
#info h1 {
font-size: 2.5em;
opacity: 0.8;
}
#info h2 {
font-size: 1.2em;
opacity: 0.6;
}
</style>
</head>
<div id='map'></div>
<div id='title'>
<h1 style="color: #a0a0a0">2020: <span id="total-2020">1278.78km</span></h1>
<h1 style="color: #c0c0c0">2021: <span id="total-2021">976km</span></h1>
<h1 style="color: #fafafa">2022: <span id="total-2022">0km</span></h1>
</div>
<div id='info'></div>
<script>
let zoom = 11
let center = [59.287630320343276, 18.03937911987305]
if (window.innerWidth < 960) {
zoom = 9
center = [59.24429260940369, 17.89432525634766]
}
L.mapbox.accessToken = 'pk.eyJ1IjoicGV0ZXJzZWRnZXdpY2siLCJhIjoieEJFeDlLMCJ9.T3YCoB-ZezQsWUA4Q7NaGg';
let map = L.mapbox.map('map', null, {zoomControl: false})
.setView(center, zoom)
.addLayer(L.mapbox.styleLayer('mapbox://styles/petersedgewick/cl0mbisad00bv15qlwk4106ng'));
let opa = 0.4;
colours = {
2020: "#a0a0a0",
2021: "#c0c0c0",
2022: "#fafafa",
}
var d = new Date();
for (var year in data) {
if (year == d.getFullYear()) {
opa = 1
}
for (var line in data[year]['lines']) {
opa = 0.9
var line = L.polyline(polyline.decode(data[year]['lines'][line]), {
color: colours[year],
opacity: opa,
stroke: 0.03,
lineWidth: 0.03
})
line.addTo(map);
}
}
// Populate side panel
document.getElementById('total-2020').innerHTML = Math.round(data['2020']['distance'] / 1000) + 'km'
document.getElementById('total-2021').innerHTML = Math.round(data['2021']['distance'] / 1000) + 'km'
document.getElementById('total-2022').innerHTML = Math.round(data['2022']['distance'] / 1000) + 'km'
let months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
let i = 1
for (month in months) {
let el = document.createElement('h2')
el.innerHTML = '<h2>' + months[month] + ': <span id="' + months[month] + '">' + data['2022']['months'][i.toString()] + 'km</span></h2>'
el.style.opacity = 0.3 + data['2022']['months'][i] * 2 / data['2022']['distance']
document.getElementById("info").appendChild(el)
i++
}
</script>
<body>