-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCapHillBoozeLoops.html
505 lines (449 loc) · 16.7 KB
/
CapHillBoozeLoops.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
<!--Taishi Walden V6 Hover Test
Adding a hover feature
Updating the introduction popup > updated image
add image of V logo
Making the sidebar responsive for mobile users
X Updated the style in MapBox Studio
X Took a hole out of the location marker svg
-->
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Capitol Hill Booze Loops</title>
<meta name='viewport' content="width=device-width, initial-scale=1" />
<!-- Add the `mapbox-gl-js` library to the page. This gives our JS code below access to the `mapboxgl` object -->
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.4.0/mapbox-gl.js'></script>
<!-- Add some default styling for the map container & controls -->
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.4.0/mapbox-gl.css' rel='stylesheet' />
<style>
* {
box-sizing: border-box;
}
body {
color: #404040;
font: 400 15px/22px 'Source Sans Pro', 'Helvetica Neue', sans-serif;
margin: 0;
padding: 0;
-webkit-font-smoothing: antialiased;
}
h1 {
/*font-size: 31px;*/
font: 31px 'Poppins';
margin: 0;
color: #000000;
font-weight: bold;
line-height: 20px;
padding: 20px 2px;
}
h2 {
text-align: center;
}
h3 {
text-align: center;
color: #0036ac;
font: 16px 'Poppins';
font-weight: bold;
}
a {
color: #404040;
text-decoration: none;
}
a:hover {
color: #101010;
}
/* The page is split between map and sidebar - the sidebar gets 1/3, map
gets 2/3 of the page. You can adjust this to your personal liking. */
.sidebar {
position: absolute;
width: 25%;
height: 100%;
top: 0;
left: 0;
overflow: hidden;
border-right: 1px solid rgba(13, 47, 240, 0.25);
}
.map {
position: absolute;
left: 25%;
width: 75%;
top: 0;
bottom: 0;
}
.heading {
background: #FFBC42;
border-bottom: 1px solid #eee;
text-align: center;
height: 130px;
line-height: 60px;
padding: 0 10px;
}
.listings {
height: 100%;
overflow: auto;
padding-bottom: 60px;
}
.listings .item {
border-bottom: 1px solid rgb(97, 97, 97);
padding: 20px;
text-decoration: none;
}
.listings .item:last-child {
border-bottom: 10px solid #FFBC42;
}
.listings .item .title {
display: block;
color: #0036ac;
font-weight: 700;
}
.listings .item .title small {
font-weight: 400;
}
.listings .item.active .title,
.listings .item .title:hover {
color: #3893dd;
}
.listings .item.active {
background-color: #f8f8f8;
}
::-webkit-scrollbar {
width: 3px;
height: 3px;
border-left: 0;
background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-track {
background: none;
}
::-webkit-scrollbar-thumb {
background: #0044d8;
border-radius: 0;
}
.marker {
border: none;
cursor: pointer;
height: 55px;
width: 36px;
background-image: url('Images/CapHillMarker.svg');
}
.mapboxgl-popup {
padding-bottom: 50px;
}
</style>
</head>
<body>
<div class='sidebar'> <!-- Add a #map and #sidebar element to the page, to serve as the map's container -->
<div class='heading'>
<h1>Booze Loops</h1>
<h2>–– Capitol Hill ––</h2>
</div>
<div id='listings' class='listings'></div>
</div>
<div id="map" class="map"></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoidGFpc2hpd2FsZGVuIiwiYSI6ImNrcXkzaWJvbzE0Zzgyd21mZHVjNDBvYmIifQ.E2__hXdmUMAPh2zjvGjJgw';
// Set an access token to allow the browser to load the map from our account
const map = new mapboxgl.Map({ // Instantiate a new Map object to load the map itself
style: 'mapbox://styles/taishiwalden/ckv4dc46a3qlk15r03duipl6i', // This tells the map which style to use
container: 'map', // id of the container div we created above
center: [-122.314, 47.6133], // the location to display when the map first loads
zoom: 10, // the zoom level to display when the map first loads
minZoom: 10,
maxZoom: 18,
pitch: 0 // pitch in degrees
});
const stores = {
"type": "FeatureCollection", //1: Unicorn Bar
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-122.317570, //find these coordinates on MapBox itself
47.614297
]
},
"properties": {
"phoneFormatted": "(206) 297-0507",
"phone": "2062970507",
"address": "Unicorn Bar",//shows up in sidebar
"city": "1118 E Pike St", //city shows up on sidebar
"country": "United States",
"crossStreet": "2026 NW Market St",
"postalCode": "98107",
"state": "WA",
"imagename": "kangarooandkiwi.jpg", //included
"description": "If it’s someone’s birthday, order them a unicorn jizz and make them wear “the hat" //included
}
},
{
"type": "Feature", //2: Rhein Haus
"geometry": {
"type": "Point",
"coordinates": [
-122.31648,
47.610851
]
},
"properties": {
"phoneFormatted": "(206) 782-5182",
"phone": "2067825182",
"address": "Rhein Haus", //shows up in sidebar
"city": "912 12th Ave", //city shows up on sidebar
"country": "United States",
"crossStreet": "at 22nd St NW",
"postalCode": "20037",
"state": "D.C.",
"imagename": "shingletownsaloon.jpeg",
"description": "update description"
}
},
{
"type": "Feature", //3: Comet Tavern
"geometry": {
"type": "Point",
"coordinates": [
-122.319674,
47.614143
]
},
"properties": {
"phoneFormatted": "(206) 258-2162",
"phone": "2062582162",
"address": "Comet Tavern", //shows up in sidebar
"city": "922 E Pike St", //city shows up on sidebar
"country": "United States",
"crossStreet": "at Dupont Circle",
"postalCode": "20036",
"state": "WA",
"imagename": "ponoranch.jpeg",
"description": "Update description"
}
},
{
"type": "Feature", //4: Capitol Cider
"geometry": {
"type": "Point",
"coordinates": [
-122.321153,
47.614074
]
},
"properties": {
"phoneFormatted": "(206) 829-9615",
"phone": "2068299615",
"address": "Capitol Cider", //shows up in sidebar
"city": "818 E Pike St", //shows up in sidebar
"country": "United States",
"crossStreet": "at 34th St NW",
"postalCode": "20007",
"state": "WA",
"imagename": "skalbeerhall.jpeg",
"description": "Update description"
}
},
{
"type": "Feature", //5: The Rhino Room
"geometry": {
"type": "Point",
"coordinates": [
-122.318404,
47.615032
]
},
"properties": {
"phoneFormatted": "(206) 258-3900",
"phone": "2062583900",
"address": "The Rhino Room", //shows up in sidebar
"city": "1535 11th Ave", //shows up in sidebar
"country": "United States",
"crossStreet": "btwn 2nd & 3rd Sts. SE",
"postalCode": "20003",
"state": "WA",
"imagename": "sunsettavern.jpeg",
"description": "Update description"
}
},
{
"type": "Feature", //6: Queer/Bar
"geometry": {
"type": "Point",
"coordinates": [
-122.31799,
47.614754
]
},
"properties": {
"phoneFormatted": "(206) 784-4480",
"phone": "2067844480",
"address": "Queer/Bar", //shows up in sidebar
"city": "1518 11th Ave,", //shows up in sidebar
"country": "United States",
"crossStreet": "btwn 2nd & 3rd Sts. SE",
"postalCode": "20003",
"state": "WA",
"imagename": "sunsettavern.jpeg",
"description": "Update description"
}
},
{
"type": "Feature", //7: Optimism Brewing Company
"geometry": {
"type": "Point",
"coordinates": [
-122.320571,
47.612816
]
},
"properties": {
"phoneFormatted": "(206) 789-3599",
"phone": "2067893599",
"address": "Optimism Brewing Company",
"city": "1158 Broadway",
"country": "United States",
"crossStreet": "btwn 2nd & 3rd Sts. SE",
"postalCode": "20003",
"state": "WA",
"imagename": "tractortavern.jpeg",
"description": "Update description"
}
}
]
};
/** Assign a unique id to each store. You'll use this `id`
* later to associate each point on the map with a listing in the sidebar.*/
stores.features.forEach((store, i) => {
store.properties.id = i;
});
function buildLocationList(stores) {
for (const store of stores.features) {
const listings = document.getElementById('listings'); /*Add a new listing section to the sidebar.*/
const listing = listings.appendChild(document.createElement('div'));
listing.id = `listing-${store.properties.id}`; /*Assign a unique `id` to the listing.*/
listing.className = 'item'; /*Assign the `item` class to each listing for styling.*/
const link = listing.appendChild(document.createElement('a')); /*Add the link to the individual listing created above.*/
link.href = '#';
link.className = 'title';
link.id = `link-${store.properties.id}`;
link.innerHTML = `${store.properties.address}`;
/* Add details to the individual listing. */
const details = listing.appendChild(document.createElement('div'));
details.innerHTML = `${store.properties.city}`;
if (store.properties.phone) {
details.innerHTML += ` · ${store.properties.phoneFormatted}`;
}
if (store.properties.distance) {
const roundedDistance = Math.round(store.properties.distance * 100) / 100;
details.innerHTML += `<div><strong>${roundedDistance} miles away</strong></div>`;
}
link.addEventListener('click', function () { /*fire when user clicks in sidebar or when user clicks on a restaurant on the map*/
for (const feature of stores.features) {
if (this.id === `link-${feature.properties.id}`) {
flyToStore(feature);
createPopUp(feature);
}
}
const activeItem = document.getElementsByClassName('active');
if (activeItem[0]) {
activeItem[0].classList.remove('active');
}
this.parentNode.classList.add('active');
});
}
}
function flyToStore(currentFeature) {
map.flyTo({
center: currentFeature.geometry.coordinates,
zoom: 15
});
}
function createPopUp(currentFeature) {
const popUps = document.getElementsByClassName('mapboxgl-popup');
/** Check if there is already a popup on the map and if so, remove it */
if (popUps[0]) popUps[0].remove();
const popup = new mapboxgl.Popup({ closeOnClick: false }) //Popup for each venue
.setLngLat(currentFeature.geometry.coordinates)
.setHTML(`<h3>${currentFeature.properties.address}</h3><h4>${currentFeature.properties.description}</h4>` +
`<a><img alt="venue image" src="Images/${currentFeature.properties.imagename}" + width="220" height="220"></a>`)
.addTo(map);
}
function rotate() {
map.easeTo({ bearing: 40, duration: 5000, pitch: 40, zoom: 15 }); // 1000ms = 1 second
window.setTimeout(() => {
}, 10000);
}
map.on('load', () => {
rotate();
delay();
/*setTimeout(function delay(){
// call the plugin here
},5000); // 1000ms = 1 second */
map.addSource('places', {
type: 'geojson',
data: stores
});
function addMarkers() {
/* For each feature in the GeoJSON object above: */
for (const marker of stores.features) {
/* Create a div element for the marker. */
const el = document.createElement('div');
/* Assign a unique `id` to the marker. */
el.id = `marker-${marker.properties.id}`;
/* Assign the `marker` class to each marker for styling. */
el.className = 'marker';
/** Create a marker using the div element
* defined above and add it to the map.
**/
new mapboxgl.Marker(el, { offset: [0, -23] })
.setLngLat(marker.geometry.coordinates)
.addTo(map);
el.addEventListener('click', (e) => {
/* Fly to the point */
flyToStore(marker);
/* Close all other popups and display popup for clicked store */
createPopUp(marker);
/* Highlight listing in sidebar */
const activeItem = document.getElementsByClassName('active');
e.stopPropagation();
if (activeItem[0]) {
activeItem[0].classList.remove('active');
}
const listing = document.getElementById(`listing-${marker.properties.id}`
);
listing.classList.add('active');
});
}
}
buildLocationList(stores);
addMarkers();
});
function delay(){
IntroPop = setTimeout(IntroPopup, 5000);
var IntroPopup = new mapboxgl.Popup({ closeOnClick: false }) //introduction popup when it first initiates
.setLngLat([-122.308882, 47.612907])
.setHTML('<h2 style="color:black;">Welcome to Booze Loops!</h2>' +
'<a href="https://www.google.com/"><img alt="Intro" src="Images/boozeloopsintro.png" width=220" height="220"></a>')
.addTo(map);
}
/*var IntroPopup = new mapboxgl.Popup({ closeOnClick: false }) //introduction popup when it first initiates
.setLngLat([-122.3741, 47.6699])
.setHTML('<h2 style="color:black;">Welcome to Booze Loops!</h2>' +
'<a href="https://www.google.com/"><img alt="Intro" src="Images/boozeloopsintro.png" width=220" height="220"></a>')
.addTo(map); */
const clickedFeatures = map.queryRenderedFeatures(event.point, { layers: [ 'symbols']});
if (clickedFeatures.length > 0) {
clicked.title = clickedFeatures[0].properties.title;
clicked.description = clickedFeatures[0].properties.description;
clicked.imagename = clickedFeatures[0].properties.imagename;
console.log("imagename: ", clickedFeatures[0].properties);
const popup = new mapboxgl.Popup() // create the popup
.setLngLat(clicked.location.center) // position it at the clicked point
.setHTML('<h3>' + clicked.title + '</h3><p>' + clicked.description + '</p>' +
'<a href="https://www.google.com/"><img alt="Intro" src="Images/' + clicked.imagename + '"' + 'width="220" height="220"></a>') // add some HTML content
.addTo(map); // place the popup on the map
}
console.log(JSON.stringify(clicked, null, 2));
</script>
</body>
</html>