-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
347 lines (304 loc) · 14.2 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="icon"
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌬️</text></svg>">
<title>Wind</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/picnic">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI=" crossorigin="" />
<script defer data-domain="wind.luissilva.eu" src="https://analytics.luissilva.eu/js/script.js"></script>
<style>
#map {
height: 100%;
}
.container {
padding: 23px;
}
.demo {
align-items: baseline;
justify-content: space-between;
}
</style>
</head>
<body>
<div class="flex two-1200 one-600" style="height: 100%;">
<div>
<div class="container">
<h1>Wind Energy Size</h1>
<p>
Welcome to my personal website where you can have fun exploring wind blade sizes! Get ready to see
some cool stuff as we superimpose wind blade radius sizes onto map images. Ever wondered how big
those wind turbine blades really are? Well, now you can visualize it yourself! Take a virtual tour
and see how the radius of different wind blade sizes compares to specific locations on the map.
Made with 🧡 by <a href="https://about.luissilva.eu">me</a>
</p>
<h3>Select a location <span>(use google maps to find the coordinates)</span></h3>
<div class="flex four demo">
<input class="three-fourth" type="text" id="coordinates"
placeholder="55.68425837121026, 12.593041555270815">
<button id="search" class="primary" style="max-width: 100px;">Search</button>
<button id="current-location" class="primary" style="max-width: 100px;">Current</button>
</div>
<div class="flex four demo">
<input class="three-fourth" type="text" id="place-search" placeholder="Search for a place...">
<button id="search-place" class="primary" style="max-width: 100px;">Find</button>
</div>
<h3>Choose your Blade</h3>
<div class="tabs three">
<input id="tab-1" type="radio" name="tabgroupB" checked="">
<label class="pseudo button toggle" for="tab-1">V236 (Vestas)</label>
<input id="tab-2" type="radio" name="tabgroupB">
<label class="pseudo button toggle" for="tab-2">SG 14-222 DD</label>
<input id="tab-3" type="radio" name="tabgroupB">
<label class="pseudo button toggle" for="tab-3">Haliade-X</label>
<div class="row">
<div>
<table class="primary">
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Name</td>
<td>V236</td>
</tr>
<tr>
<td>Manufacturer</td>
<td>Vestas</td>
</tr>
<tr>
<td>Status</td>
<td>Prototype</td>
</tr>
<tr>
<td>Diameter (m)</td>
<td>236</td>
</tr>
<tr>
<td>Power (MW)</td>
<td>15</td>
</tr>
</tbody>
</table>
<button class="success" onclick="addCurrentBlade()">Add to Map</button>
</div>
<div>
<table class="primary">
<tbody>
<tr>
<td>Name</td>
<td>SG 14-222 DD</td>
</tr>
<tr>
<td>Manufacturer</td>
<td>Siemens Gamesa</td>
</tr>
<tr>
<td>Status</td>
<td>Production</td>
</tr>
<tr>
<td>Diameter (m)</td>
<td>222</td>
</tr>
<tr>
<td>Power (MW)</td>
<td>14</td>
</tr>
</tbody>
</table>
<button class="success" onclick="addCurrentBlade()">Add to Map</button>
</div>
<div>
<table class="primary">
<tbody>
<tr>
<td>Name</td>
<td>Haliade-X</td>
</tr>
<tr>
<td>Manufacturer</td>
<td>GE</td>
</tr>
<tr>
<td>Status</td>
<td>Production</td>
</tr>
<tr>
<td>Diameter (m)</td>
<td>220</td>
</tr>
<tr>
<td>Power (MW)</td>
<td>12-14</td>
</tr>
</tbody>
</table>
<button class="success" onclick="addCurrentBlade()">Add to Map</button>
</div>
</div>
</div>
<br>
<button class="error" onclick="clearBlades()">Clear All Blades</button>
</div>
</div>
<div id="map"></div>
</div>
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM=" crossorigin=""></script>
<script>
let coords = [55.68425837121026, 12.593041555270815];
let map = L.map('map').setView(coords, 17);
let circles = []; // Array to store all circles
let locationMarker; // Store the location marker
const bladeData = {
'tab-1': { diameter: 236, color: '#f03' },
'tab-2': { diameter: 222, color: '#30f' },
'tab-3': { diameter: 220, color: '#3f0' }
};
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
// Function to update location marker
function updateLocationMarker(coords) {
// Remove existing marker if it exists
if (locationMarker) {
map.removeLayer(locationMarker);
}
// Create a new marker with a popup
locationMarker = L.marker(coords)
.bindPopup('Selected Location')
.addTo(map)
.openPopup();
}
// Function to update location
function updateLocation(newCoords) {
coords = newCoords;
map.setView(coords, 17);
// Update input field
const coordsInput = document.getElementById('coordinates');
coordsInput.value = coords.join(', ');
// Update the location marker
updateLocationMarker(coords);
}
// Initialize the location marker at the starting position
updateLocationMarker(coords);
// Function to add current blade selection to map
function addCurrentBlade() {
const selectedTab = document.querySelector('input[name="tabgroupB"]:checked').id;
const blade = bladeData[selectedTab];
const circle = L.circle(coords, {
color: blade.color,
fillColor: blade.color,
fillOpacity: 0.5,
radius: blade.diameter / 2
}).addTo(map);
circles.push(circle);
}
// Function to clear all blades
function clearBlades() {
circles.forEach(circle => map.removeLayer(circle));
circles = [];
}
// Add click event listener to map
map.on('click', function (e) {
updateLocation([e.latlng.lat, e.latlng.lng]);
});
// listen to the search button and updates the coords array
const searchButton = document.getElementById('search');
searchButton.addEventListener('click', () => {
const coordsInput = document.querySelector('input[type="text"]');
try {
const newCoords = coordsInput.value.split(',').map(coord => parseFloat(coord));
updateLocation(newCoords);
} catch (error) {
console.log(error);
alert('Invalid coordinates');
}
});
// Add place search functionality
const searchPlaceButton = document.getElementById('search-place');
const placeInput = document.getElementById('place-search');
searchPlaceButton.addEventListener('click', async () => {
const place = placeInput.value;
if (!place) return;
try {
const response = await fetch(`https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(place)}`);
const data = await response.json();
if (data && data.length > 0) {
const location = data[0];
updateLocation([parseFloat(location.lat), parseFloat(location.lon)]);
} else {
alert('Place not found');
}
} catch (error) {
console.error(error);
alert('Error searching for place');
}
});
// Also allow pressing Enter to search
placeInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
searchPlaceButton.click();
}
});
// 40.639495008164715, -7.9438916760787075
// 55.69299598118794, 12.102477221553233
// 55.68425837121026, 12.593041555270815
// Add current location functionality
const currentLocationButton = document.getElementById('current-location');
// Remove the disabled attribute
currentLocationButton.removeAttribute('disabled');
currentLocationButton.addEventListener('click', () => {
if (!navigator.geolocation) {
alert('Geolocation is not supported by your browser');
return;
}
currentLocationButton.setAttribute('disabled', '');
currentLocationButton.textContent = 'Loading...';
navigator.geolocation.getCurrentPosition(
(position) => {
// Success callback
const newCoords = [position.coords.latitude, position.coords.longitude];
updateLocation(newCoords);
// Reset button
currentLocationButton.removeAttribute('disabled');
currentLocationButton.textContent = 'Current';
},
(error) => {
// Error callback
let message = 'Error getting your location: ';
switch (error.code) {
case error.PERMISSION_DENIED:
message += 'Permission denied';
break;
case error.POSITION_UNAVAILABLE:
message += 'Position unavailable';
break;
case error.TIMEOUT:
message += 'Request timed out';
break;
default:
message += 'Unknown error';
}
alert(message);
// Reset button
currentLocationButton.removeAttribute('disabled');
currentLocationButton.textContent = 'Current';
},
{
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
}
);
});
</script>
</body>
</html>