-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
396 lines (366 loc) · 11.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Null Island(s)</title>
<meta property="og:description" content="Use flyTo with flyOptions to slowly zoom to a location." />
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel='stylesheet' href='https://unpkg.com/[email protected]/dist/maplibre-gl.css' />
<script src='https://unpkg.com/[email protected]/dist/maplibre-gl.js'></script>
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
</style>
</head>
<body>
<style>
#fly {
display: block;
position: absolute;
top: 20px;
left: 50%;
transform: translate(-50%);
width: 50%;
height: 40px;
padding: 10px;
border: none;
border-radius: 3px;
font-size: 12px;
text-align: center;
color: #000;
background: #ffff00;
}
#more {
display: block;
position: absolute;
bottom: 40px;
right: 10px;
padding: 10px;
border: none;
font-size: 12px;
font-family: Helvetica, Arial, sans-serif;
text-align: center;
color: #000;
background: #ffff00;
}
a {
color: #000;
text-decoration: none;
}
</style>
<div id="map"></div>
<br />
<button id="fly">Zoom in/out</button>
<div id="more"><a href="https://github.com/stamen/null-island/">Learn more</a></div>
<script>
const start = 23.5;
const end = 2;
const target = [0, 0];
const map = new maplibregl.Map({
container: 'map',
hash: true,
style:
'https://tiles.stadiamaps.com/styles/stamen_toner.json',
center: target,
maxZoom: 23.5,
zoom: 18
});
let scale = new maplibregl.ScaleControl({
maxWidth: 200,
unit: 'metric'
});
map.addControl(scale);
let scale2 = new maplibregl.ScaleControl({
maxWidth: 200,
unit: 'imperial'
});
map.addControl(scale2);
map.addControl(new maplibregl.FullscreenControl({container: document.querySelector('body')}));
map.addControl(new maplibregl.NavigationControl());
map.once("load", () => {
map.addSource("null-island-nixta-label-point", {
type: "geojson",
data: {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [0, -0.05]
},
'properties': {
'name':
"Null Island\nnixta's version circa 2014\n63.8 km²",
}
}
]
}
});
map.addSource("null-island-natural-earth-v4-label-point", {
type: "geojson",
data: {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [0, -0.008]
},
'properties': {
'name':
"Null Island\nNatural Earth v4.1 circa 2018\n1 km²",
}
}
]
}
});
map.addSource("null-island-original-label-point", {
type: "geojson",
data: {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [0, -0.0004]
},
'properties': {
'name':
"Null Island\noriginal version circa 2010\n3,433 m²",
}
}
]
}
});
map.addSource("null-island-natural-earth-v1-label-point", {
type: "geojson",
data: {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [0, -0.000008]
},
'properties': {
'name':
"Null Island\nNatural Earth v1.3 circa 2011\n1 m²",
}
}
]
}
});
map.addSource("null-island-nixta", {
type: "geojson",
data: "data/null-island-nixta.geojson"
});
map.addLayer({
id: "null-island-nixta-layer",
type: "fill",
source: "null-island-nixta",
paint: {
"fill-color": "#cccccc",
"fill-opacity": 1,
"fill-outline-color": "black",
}
});
map.addLayer({
id: "null-island-nixta-label",
type: "symbol",
source: "null-island-nixta-label-point",
minzoom: 9,
maxzoom: 13,
layout: {
"symbol-placement": "point",
"text-font": ["Inter Regular"],
"text-field": ['get', 'name'],
"text-max-width": 100,
"text-size": [
'interpolate',
['exponential', 2],
['zoom'],
9, 6,
13, 96
]
},
paint: {
"text-color": "white",
"text-opacity": [
'interpolate',
['linear'],
['zoom'],
9, 0,
10, 1,
12, 1,
13, 0
]
}
});
map.addSource("null-island-natural-earth-v4", {
type: "geojson",
data: "data/null-island-natural-earth-v4.geojson"
});
map.addLayer({
id: "null-island-natural-earth-v4-layer",
type: "fill",
source: "null-island-natural-earth-v4",
paint: {
"fill-color": "#dddddd",
"fill-opacity": 1,
"fill-outline-color": "black",
}
});
map.addLayer({
id: "null-island-natural-earth-v4-label",
type: "symbol",
source: "null-island-natural-earth-v4-label-point",
minzoom: 12,
maxzoom: 16,
layout: {
"symbol-placement": "point",
"text-font": ["Inter Regular"],
"text-field": ['get', 'name'],
"text-max-width": 100,
"text-size": [
'interpolate',
['exponential', 2],
['zoom'],
11, 6,
16, 96
]
},
paint: {
"text-opacity": [
'interpolate',
['linear'],
['zoom'],
12, 0,
13, 1,
15, 1,
16, 0
]
}
});
map.addSource("null-island-original", {
type: "geojson",
data: "data/null-island-original.geojson"
});
map.addLayer({
id: "null-island-original-layer",
type: "fill",
source: "null-island-original",
paint: {
"fill-color": "#eeeeee",
"fill-opacity": 1,
"fill-outline-color": "black",
}
});
map.addLayer({
id: "null-island-original-label",
type: "symbol",
source: "null-island-original-label-point",
minzoom: 15,
maxzoom: 20,
layout: {
"symbol-placement": "point",
"text-font": ["Inter Regular"],
"text-field": ['get', 'name'],
"text-max-width": 100,
"text-size": [
'interpolate',
['exponential', 2],
['zoom'],
15, 3,
20, 96
]
},
paint: {
"text-opacity": [
'interpolate',
['linear'],
['zoom'],
15, 0,
16, 1,
19, 1,
20, 0
]
}
});
map.addSource("null-island-natural-earth-v1", {
type: "geojson",
data: "data/null-island-natural-earth-v1.geojson"
});
map.addLayer({
id: "null-island-natural-earth-v1-layer",
type: "fill",
source: "null-island-natural-earth-v1",
paint: {
"fill-color": "white",
"fill-opacity": 1,
"fill-outline-color": "black",
}
});
map.addLayer({
id: "null-island-natural-earth-v1-label",
type: "symbol",
source: "null-island-natural-earth-v1-label-point",
minzoom: 21,
layout: {
"symbol-placement": "point",
"text-font": ["Inter Regular"],
"text-field": ['get', 'name'],
"text-max-width": 100,
"text-size": [
'interpolate',
['exponential', 2],
['zoom'],
20, 3,
24, 24
]
},
paint: {
"text-opacity": [
'interpolate',
['linear'],
['zoom'],
21, 0,
22, 1
]
}
});
map.showCollisionBoxes(true);
});
let isAtStart = true;
document.getElementById('fly').addEventListener('click', () => {
// depending on whether we're currently at point a or b, aim for
// point a or b
const targetZoom = isAtStart ? end : start;
// and now we're at the opposite point
isAtStart = !isAtStart;
map.flyTo({
// These options control the ending camera position: centered at
// the target, at zoom level 9, and north up.
center: target,
zoom: targetZoom,
bearing: 0,
// These options control the flight curve, making it move
// slowly and zoom out almost completely before starting
// to pan.
speed: 1, // make the flying slow
curve: 1, // change the speed at which it zooms out
// This can be any easing function: it takes a number between
// 0 and 1 and returns another number between 0 and 1.
easing (t) {
return t;
},
// this animation is considered essential with respect to prefers-reduced-motion
essential: true
});
});
</script>
</body>
</html>