-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·524 lines (487 loc) · 14.9 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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8" />
<!-- HTML Meta Tags -->
<title>Best SUP Spots of the PacNW</title>
<meta name="description" content="" />
<!-- Google / Search Engine Tags -->
<meta itemprop="name" content="Best SUP Spots of the PacNW" />
<meta
itemprop="description"
content="Find the best places to SUP around the Pacific Northwest"
/>
<meta
itemprop="image"
content="https://supmap.org/assets/img/bestsup.png"
/>
<!-- Facebook Meta Tags -->
<meta property="og:url" content="https://supmap.org" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Best SUP Spots of the PacNW" />
<meta
property="og:description"
content="Find the best places to SUP around the Pacific Northwest"
/>
<meta
property="og:image"
content="https://supmap.org/assets/img/bestsup.png"
/>
<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Best SUP Spots of the PacNW" />
<meta
name="twitter:description"
content="Find the best places to SUP around the Pacific Northwest"
/>
<meta
name="twitter:image"
content="https://supmap.org/assets/img/bestsup.png"
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css?family=Bungee|Bungee+Shade&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Outfit:[email protected]&display=swap"
rel="stylesheet"
/>
<link
href="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.css"
rel="stylesheet"
/>
<script src="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.js"></script>
<!-- include weather.js -->
<script src="./assets/js/weather.js"></script>
<style>
body {
margin: 0;
padding: 0;
font-family: "Open Sans", sans-serif;
-webkit-font-smoothing: antialiased;
}
* {
box-sizing: border-box;
}
.map {
position: absolute;
height: 100%;
width: 100%;
}
a {
color: #404040;
text-decoration: none;
}
a:hover {
color: #101010;
}
.title-bar {
display: flex;
position: absolute;
background-color: rgb(35, 100, 106, 0.9);
color: #fff;
width: 100%;
z-index: 1;
top: 36px;
justify-content: space-evenly;
align-items: center;
}
.title-bar .logo {
padding: 10px;
}
.title-bar .share {
position: fixed;
top: 13px;
right: 20px;
}
.title-bar h1 {
font-family: "Bungee", Arial, Helvetica, sans-serif;
font-size: 4em;
font-style: italic;
font-variation-settings: "wdth" 75;
text-transform: uppercase;
margin: 0;
padding: 20px 2px;
}
.title-bar h3 {
font-family: "Bungee", Arial, Helvetica, sans-serif;
font-size: 1.17em;
}
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed;
z-index: 10;
left: 10px;
top: 20%;
width: 24%;
height: 70%;
overflow-y: scroll;
overflow-x: hidden;
background-color: rgb(255, 255, 255);
padding: 20px;
border-radius: 20px;
box-shadow: 0px 1px 8px 0px rgba(0, 0, 0, 0.25);
}
/* Modal Content/Box */
.modal-content {
font-family: "Outfit", sans-serif;
font-optical-sizing: auto;
/* font-weight: <weight>; */
font-style: normal;
font-size: 0.85em;
margin-top: 20px;
width: 100%; /* Could be more or less, depending on screen size */
line-height: 1.25em;
}
.modal-content img {
margin-top: 20px;
width: 100%;
height: auto;
/* round corners */
border-radius: 10px;
/* add shadow */
box-shadow: 0px 1px 8px 0px rgba(0, 0, 0, 0.25);
}
.modal h3 {
font-family: "Bungee", sans-serif;
color: #23646a;
font-size: 2em;
}
/* The Close Button */
.close {
position: absolute;
color: #aaa;
font-size: 28px;
font-weight: bold;
top: 16px;
right: 20px;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
.poster {
margin-right: 8px;
width: 100%;
border-radius: 10px;
/* add shadow */
box-shadow: 0px 1px 8px 0px rgba(0, 0, 0, 0.25);
margin-bottom: 10px;
}
/* banner */
.banner {
position: absolute;
display: flex;
top: 0;
left: 0;
width: 100%;
background-color: #ec6157;
color: #fff;
padding: 10px;
font-size: 12px;
justify-content: center;
align-items: baseline;
z-index: 5;
border-bottom: #c8c7b2 2px solid;
}
.banner a {
color: #fff;
text-decoration: underline;
}
.spot {
color: #23646a;
}
.mapboxgl-popup {
max-width: 400px;
font: 12px/20px "Helvetica Neue", Arial, Helvetica, sans-serif;
padding-bottom: 10px;
}
.mapboxgl-popup,
img {
max-width: 100%;
}
.mapboxgl-popup-content {
border-radius: 10px;
color: #ffffff;
background: #23646a;
}
.mapboxgl-popup-content img {
background-color: rgba(255, 255, 255, 1);
/* max-width: 66px; */
position: relative;
left: 0px;
margin: 10px 0px;
border: solid 0.5px #e7e0d4;
border-radius: 10px;
}
.mapboxgl-popup-content a {
color: #ffffff;
line-height: 2em;
}
.mapboxgl-popup-content h2,
p {
margin-bottom: 5px;
}
.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip {
border-top-color: #23646a;
}
.mapboxgl-popup-anchor-top .mapboxgl-popup-tip {
border-bottom-color: #23646a;
}
.mapboxgl-popup-anchor-left .mapboxgl-popup-tip {
border-right-color: #23646a;
}
.mapboxgl-popup-anchor-right .mapboxgl-popup-tip {
border-left-color: #23646a;
}
.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip {
border-bottom-color: #23646a;
}
.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip {
border-bottom-color: #23646a;
}
.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip {
border-top-color: #23646a;
}
.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip {
border-top-color: #23646a;
}
::-webkit-scrollbar {
display: none;
}
::-webkit-scrollbar-track {
background: none;
}
::-webkit-scrollbar-thumb {
background: #03094d;
border-radius: 0;
}
/* create media queries for mobile */
@media (max-width: 600px) {
.title-bar {
box-shadow: 0px 2px 8px 1px rgba(0, 0, 0, 0.4);
}
.title-bar h1 {
font-size: 2em;
text-align: left;
display: inline;
padding: 0px;
}
.title-bar h3 {
font-size: 1em;
display: inline;
font-family: "Bungee", sans-serif;
}
.listings .item {
font-size: 0.5em;
}
.modal {
width: 95%;
}
}
@media (max-width: 600px) {
}
</style>
</head>
<body onload="getWeather()">
<!-- <div>Portland 🌤 conditions: </div> -->
<div class="banner">
🌡️ <span id="airfTemp" class="item">79</span>°F
<span id="aircTemp" class="item">26</span>°C | 💨
<span id="wind" class="item">9</span> mph |
<a
href="https://player.streamguys.com/allclassical/tilicam/sgplayer/player.php"
class="item"
>
Live 📸</a
>  |
<a href="https://www.buymeacoffee.com/supr" class="item">Donate 💸</a
>
</div>
<div class="title-bar">
<div class="logo">
<img src="./assets/img/logo.png" alt="SUP" />
</div>
<h1>best sup spots</h1>
<h3>of the pacnw</h3>
</div>
<div id="myModal" class="modal"></div>
<div id="map" class="map"></div>
<script>
mapboxgl.accessToken =
"pk.eyJ1IjoiZ3JhZmEiLCJhIjoiY2tkb3ZoNzZrMDZyMzMxbGo0YTF3ZHk2ZyJ9.u6m6_Sxxu5ITBuomsTyA3g";
const map = new mapboxgl.Map({
container: "map",
style: "mapbox://styles/grafa/ckdhx8rpo01b61ip8o9e8fth3",
center: [-122.3345875083181, 45.078029776299076],
zoom: 7,
hash: false,
// cooperativeGestures: true,
attributionControl: false,
}).addControl(
new mapboxgl.AttributionControl({
customAttribution:
'<a href="https://www.oregon.gov/OSMB/Pages/index.aspx">OSMB</a>',
})
);
// write a async function to fetch the supspots.geojson file in the ./geojson folder
const getSupSpots = async () => {
const response = await fetch("./assets/geojson/supspots.geojson");
const data = await response.json();
return data;
};
/**
* Wait until the map loads to make changes to the map.
*/
map.on("load", async () => {
const data = await getSupSpots();
// add source and layer for spots
map.addSource("sup_spots", {
type: "geojson",
data: data,
cluster: true,
clusterMaxZoom: 14, // Max zoom to cluster points on
clusterRadius: 50, // Radius of each cluster when clustering points (defaults to 50)
generateId: true,
});
// +++++++++++++ SUP SPOTS +++++++++++++
// add the layers for the clusters and unclustered points
map.addLayer({
id: "spot_clusters",
type: "circle",
source: "sup_spots",
filter: ["all", [">", "point_count", 0]],
paint: {
"circle-color": "#ec6157",
"circle-radius": ["step", ["get", "point_count"], 8, 1, 16, 3, 24],
"circle-stroke-width": 2,
"circle-stroke-color": "#fff",
},
});
// add the unclustered points layer
map.addLayer({
id: "spot_unclustered_points",
type: "symbol",
source: "sup_spots",
// create a filter that will hide the clusters and only show the points
filter: ["!", ["has", "point_count"]],
layout: {
"icon-image": "spots",
"icon-size": 0.5,
"icon-allow-overlap": true,
},
});
// add a label layer for the clusters
map.addLayer({
id: "spot_cluster_count",
type: "symbol",
source: "sup_spots",
filter: ["has", "point_count"],
layout: {
"text-field": "{point_count_abbreviated}",
"text-font": ["Arial Unicode MS Bold", "DIN Offc Pro Medium"],
"text-size": 16,
},
paint: {
"text-color": "#fff",
},
});
// add a listener for the click event on the clusters to expand the cluster and zoom in
map.on("click", "spot_clusters", (e) => {
const features = map.queryRenderedFeatures(e.point, {
layers: ["spot_clusters"],
});
const clusterId = features[0].properties.cluster_id;
map
.getSource("sup_spots")
.getClusterExpansionZoom(clusterId, (err, zoom) => {
if (err) return;
map.easeTo({
center: features[0].geometry.coordinates,
zoom: zoom,
});
});
});
// add a listener for the click event on the unclustered points to display a popup
map.on("click", "spot_unclustered_points", (e) => {
const coordinates = e.features[0].geometry.coordinates.slice();
const { title, image, description } = e.features[0].properties;
const heading = `<h3>${title}</h3>`;
const desc = `
<img src='./assets/img/close_dark.svg' class='close' onclick='closeModal()' />
<img src='${image}' class='poster' />
<div class='modal-content' id='desc'>${description}</div>`;
var modal = document.getElementById("myModal");
modal.innerHTML = heading + " " + desc;
modal.style.display = "block";
});
});
map.on("click", "osmw-launches", (e) => {
// add a popup for the launches layer
let popup = new mapboxgl.Popup()
.setLngLat(e.lngLat)
.setHTML(
"<h3>" +
e.features[0].properties.FACILNM +
"</h3><p>" +
e.features[0].properties.FACILTYPE +
"</p>"
)
.addTo(map);
// if the PHOTOURL property exists, add an image to the popup
if (e.features[0].properties.PHOTOURL) {
document.querySelector(
".mapboxgl-popup-content"
).innerHTML += `<img src='${e.features[0].properties.PHOTOURL}' />`;
popup.setLngLat(e.lngLat).addTo(map);
}
// if use fee exists, add it to the popup
if (e.features[0].properties.USEFEE) {
document.querySelector(
".mapboxgl-popup-content"
).innerHTML += `<p>Use Fee: ${e.features[0].properties.USEFEE}</p>`;
}
map.on("mouseleave", "osmw-launches", () => {
map.getCanvas().style.cursor = "";
popup.remove();
});
});
map.on("click", "slipways", (e) => {
// add a popup for the launches layer
// if the name exists in the properties, use that, otherwise use the 'Slipway'
const name = e.features[0].properties.NAME
? e.features[0].properties.NAME
: "Slipway";
let popup = new mapboxgl.Popup()
.setLngLat(e.lngLat)
.setHTML("<h3>Slipway</h3>")
.addTo(map);
map.on("mouseleave", "slipways", () => {
map.getCanvas().style.cursor = "";
popup.remove();
});
});
/**
* Use Mapbox GL JS's `flyTo` to move the camera smoothly
* a given center point.
**/
function flyToVenue(currentFeature) {
map.flyTo({
center: currentFeature.geometry.coordinates,
zoom: 14,
pitch: 60,
});
}
const closeModal = () => {
document.querySelector(".modal").style.display = "none";
};
</script>
</body>
</html>