-
Notifications
You must be signed in to change notification settings - Fork 58
/
image-cover-page.html
341 lines (285 loc) · 12.6 KB
/
image-cover-page.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="description" content="GeoNarrative Template" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>GeoNarrative Template</title>
<!-- <link rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,400;0,500;1,400;1,500&display=swap" /> -->
<!-- <link rel="stylesheet" href="https://api.mapbox.com/mapbox-gl-js/v2.8.1/mapbox-gl.css"> -->
<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css"> -->
<link rel="stylesheet" href="css/main.css">
<script src="https://unpkg.com/scrollama"></script>
<script src="https://api.mapbox.com/mapbox-gl-js/v2.8.1/mapbox-gl.js"></script>
</head>
<body>
<!-- loading a image as the background of the cover page -->
<section id="cover" style="background: url('img/background.jpg') no-repeat center center; background-size: cover;">
<div id="intro">
<h1>A GeoNarrative Template</h1>
<h5>This line is a place holder for subtitle</h5>
<p>This section shows where active research is happening, and on what topics to communicate on-going nature of
scientific learning. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo
ligula
eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede
justo,
fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdet a, venenatis vitae, justo.
Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi.
Aenean
vulputate
eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante,
dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum.
Aenean imperdiet.
Etiam
ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus,
tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc,
blandit
vel,
luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero
venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla
mauris sit
amet
nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc.</p>
<div class="footnote">
<span> This line is a place holder for copyright note or other footnotes.</span>
<a target="_blank" href="https://www.uw.edu"> <img src="img/uw_logo.png" width="50px"></a>
</div>
</div>
</section>
<!-- a geonarrative will have two major components, a storyboard and a script panel of a series of scenes/actions -->
<section id="geonarrative">
<!-- a storymap can present differnt types of objects, like map, chart, diagram, etc. -->
<div id="storyboard">
<!-- create the place holder element for map -->
<div id="map"></div>
</div>
<article class="scene" data-scene="0">
<h2>STEP 1: Loading Polygons</h2>
</article>
<article class="scene" data-scene="1">
<h2>STEP 2: Loading Points</h2>
</article>
<article class="scene" data-scene="2">
<h2>STEP 3: Relocate to Place A (Seattle)</h2>
</article>
<article class="scene" data-scene="3">
<h2>STEP 4: Relocate to Place B (Portland)</h2>
</article>
<article class="scene" data-scene="4">
<h2>STEP 5: Text Script</h2>
<p>This section shows where active research is happening, and on what topics to communicate on-going nature of
scientific learning. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.
Aenean massa.
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis,
ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla
vel, aliquet nec,
vulputate eget, arcu. In enim justo, rhoncus ut, imperdet a, venenatis vitae, justo. Nullam dictum felis eu pede
mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate.
</p>
<hr>
<div>
<!-- loading bootstrap icons -->
<p><i class="bi bi-person"></i> <span>2,823</span>
</p>
<p><i class="bi bi-map"></i> <span>3,520</span>
</p>
</div>
</article>
<article class="scene" data-scene="5">
<h2>STEP 6: Image </h2>
<img src="img/portland.jpg"></img>
</article>
<article class="scene fullscreen" data-scene="6">
<h2>STEP 7: Ending Page</h2>
</article>
</section>
<section id="footer">
<h2>FOOTER</h2>
</section>
<script>
// 1. Declare the maps, script panels, and different thematic layers.
let map, scriptPanel = scrollama(), countiesLayer, cellTowersLayer;
// 2. Intialize the layout.
history.scrollRestoration = "manual"; // make sure the geo-narrative will be scrolled to the cover page even after a page refresh.
window.scrollTo(0, 0); // scroll the geo-narrative to the coverpage
adjustStoryboardlSize(); // force a browser window resize.
window.addEventListener("resize", adjustStoryboardlSize); // // ask the browser window listen to the resize event, thereby force a viewport resize whenever adjusting the window size.
// 3. Define Generic window resize listener event
function adjustStoryboardlSize() {
const scenes = document.getElementsByClassName("scene");
const storyboard = document.getElementById("storyboard");
// 3.1 determine the height of each scene element
let sceneH = Math.floor(window.innerHeight * 0.75);
for (const scene of scenes) {
scene.style.height = sceneH + "px";
}
// 3.2 determin the height of the storyboard.
let storyboardHeight = window.innerHeight;
let storyboardMarginTop = (window.innerHeight - storyboardHeight) / 2;
storyboard.style.height = storyboardHeight + "px";
storyboard.style.top = storyboardMarginTop + "px"
// 3.3 tell scrollama/script panel to update new element dimensions
scriptPanel.resize();
}
// 4. Initialize the mapbox
mapboxgl.accessToken =
'pk.eyJ1IjoiamFrb2J6aGFvIiwiYSI6ImNpcms2YWsyMzAwMmtmbG5icTFxZ3ZkdncifQ.P9MBej1xacybKcDN_jehvw'; // Assign the access token
map = new mapboxgl.Map({
container: 'map', // container ID
style: 'mapbox://styles/mapbox/light-v10',
zoom: 7, // starting zoom
minZoom: 3,
maxZoom: 10,
center: [-121.93, 47.33], // starting center
scrollZoom: false,
boxZoom: false,
doubleClickZoom: false
}); // Declare the map object
// An alternative way to disable map zoom when using scroll
// map.scrollZoom.disable();
// 5. define the asynchronous function to load geojson data and then performs the dependent actions.
async function geojsonFetch() {
// 6 wait till the data of washington counties and celltowers are fully loaded.
let response, counties, celltowers;
response = await fetch("assets/wacountydata.geojson");
counties = await response.json();
response = await fetch("assets/celltowers.geojson");
celltowers = await response.json();
// 7. Trigger operations inside of the the ()=> {} funciton while loading the map.
map.on('load', () => {
// 8. add map source and declare layers.
map.addSource('celltowers-src', {
type: 'geojson',
data: celltowers
});
map.addSource('counties-src', {
type: 'geojson',
data: counties
});
countiesLayer = {
'id': 'counties-polygons',
'type': 'fill',
'source': 'counties-src',
'minzoom': 5,
'paint': {
'fill-color': '#0080ff',
'fill-opacity': 0.5
}
};
cellTowersLayer = {
'id': 'celltowers-points',
'type': 'circle',
'source': 'celltowers-src',
'minzoom': 5,
'paint': {
'circle-color': 'red',
'circle-radius': 4,
'circle-opacity': 0.8,
}
};
// 9. Initialize the script panel
scriptPanel
.setup({
step: ".scene", // all the scenes.
offset: 0.33, // the location of the enter and exit trigger
debug: false // toggler on or off the debug mode.
})
.onStepEnter(handleSceneEnter)
.onStepExit(handleSceneExit);
// 10. This function performs when a scene enters the storyboard
function handleSceneEnter(response) {
var index = response.index; // capture the id of the current scene.
if (index === 0) { // When enter the first scene
map.flyTo({
center: [-121.93, 47.33],
zoom: 8,
pitch: 0,
speed: 0.5
}); // fly to a new location
if (typeof (map.getSource('counties-src')) == 'undefined') { //if the map source 'counties-src' does not exist
map.addSource('counties-src', {
type: 'geojson',
data: counties
}); // reload the map source of 'counties-src'
} else {
map.getSource('counties-src').setData(counties); // if the map source does not exist, relaod the data counties to the pre-defined map source 'counties-src'.
}
if (!map.getLayer("counties-polygons")) { // if the map layer 'counties-polygons' does not exit
map.addLayer(countiesLayer);
}
document.getElementById("cover").style.visibility = "hidden"; // Hide the cover page
} else if (index === 1) { // When enter the second scene.
map.flyTo({
center: [-121.93, 47.33],
zoom: 8,
pitch: 60,
speed: 0.5
});
if (typeof (map.getSource('celltowers-src')) == 'undefined') {
map.addSource('celltowers-src', {
type: 'geojson',
data: celltowers
});
} else {
map.getSource('celltowers-src').setData(celltowers);
}
if (!map.getLayer("celltowers-points")) {
map.addLayer(cellTowersLayer);
}
} else if (index === 2) {
//Relocate to Seattle
map.flyTo({
center: [-122.4121036, 47.6131229],
zoom: 12,
pitch: 0,
speed: 0.5
});
} else if (index === 3) {
//Relocate to Portland
map.flyTo({
center: [-122.724366, 45.5428119],
zoom: 12,
pitch: 60,
speed: 0.5
});
map.setStyle('mapbox://styles/mapbox/satellite-streets-v10'); // change the base map
} else if (index === 6) {
map.flyTo({
center: [-122.4121036, 47.6131229],
zoom: 12,
pitch: 0,
speed: 0.5
});
}
}
// 11. This function performs when a scene exists the storyboard
function handleSceneExit(response) {
var index = response.index;
if (index === 0) {
if (map.getLayer("counties-polygons")) {
map.removeLayer('counties-polygons');
}
if (response.direction == 'down') {
document.getElementById("cover").style.visibility = "hidden"; // when you scroll down, the cover page will be hided.
} else {
document.getElementById("cover").style.visibility = "visible"; // when you scroll up, the cover page will be shown.
}
} else if (index === 1) {
if (map.getLayer("celltowers-points")) {
map.removeLayer('celltowers-points');
}
} else if (index === 3) {
//exit to Portland
map.setStyle('mapbox://styles/mapbox/light-v10');
}
}
});
};
// 5 call the data loading function.
geojsonFetch();
</script>
</body>
</html>