-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.html
292 lines (259 loc) · 9.79 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1" />
<title>The globe of extremes</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.22/esri/themes/light/main.css" />
<link rel="stylesheet" href="./style.css" />
<script>
const locationPath = location.pathname.replace(/\/[^\/]+$/, "");
dojoConfig = {
packages: [{
name: "utils",
location: locationPath + "utils"
}],
async: true
};
</script>
<script src="https://js.arcgis.com/4.22/"></script>
<script>
require([
"esri/Map",
"esri/views/SceneView",
"esri/layers/TileLayer",
"esri/layers/GeoJSONLayer",
"esri/Basemap",
"utils/ExaggeratedElevationLayer",
"esri/Graphic",
"esri/geometry/Point",
"esri/geometry/Mesh",
"esri/core/watchUtils"
], function (Map, SceneView, TileLayer, GeoJSONLayer, Basemap, ExaggeratedElevationLayer, Graphic, Point, Mesh, watchUtils) {
const R = 6358137; // approximate radius of the Earth in m
const offset = 300000; // offset from the ground used for the clouds
const basemap = new Basemap({
baseLayers: [
new TileLayer({
url: "https://tiles.arcgis.com/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/terrain_with_heavy_bathymetry/MapServer",
copyright: "Bathymetry, topography and satellite imagery from <a href=\"https://visibleearth.nasa.gov/view_cat.php?categoryID=1484\" target=\"_blank\">NASA Visible Earth</a> | <a href=\"http://www.aag.org/global_ecosystems\" target=\"_blank\">World Ecological Land Units, AAG</a> | Oceans, glaciers and water bodies from <a href=\"https://www.naturalearthdata.com/\" target=\"_blank\">Natural Earth</a>"
})
]
});
const map = new Map({
basemap: basemap
});
const view = new SceneView({
container: "viewDiv",
map: map,
alphaCompositingEnabled: true,
qualityProfile: "high",
camera: {
position: [-55.03975781, 14.94826384, 19921223.30821],
heading: 2.03,
tilt: 0.13
},
environment: {
background: {
type: "color",
color: [255, 252, 244, 0]
},
starsEnabled: false,
atmosphereEnabled: false,
lighting: {
directShadowsEnabled: false,
date: "Sun Jun 23 2019 19:19:18 GMT+0200 (Central European Summer Time)"
}
},
constraints: {
altitude: {
min: 10000000,
max: 25000000
}
},
popup: {
dockEnabled: true,
dockOptions: {
position: "top-right",
breakpoint: false,
buttonEnabled: false
},
collapseEnabled: false
},
highlightOptions: {
color: [255, 255, 255],
haloOpacity: 0.5
}
});
view.ui.remove("navigation-toggle");
map.ground.layers = [new ExaggeratedElevationLayer({
exaggerationBathymetry: 60,
exaggerationTopography: 40
})];
const origin = new Point({
x: 0, y: -90, z: -(2 * R)
});
const oceanSurfaceMesh = Mesh.createSphere(
origin, {
size: {
width: 2 * R,
depth: 2 * R,
height: 2 * R
},
densificationFactor: 5,
material: {
color: [0, 210, 210, 0.8],
metallic: 0.9,
roughness: 0.8,
doubleSided: false
}
});
const oceanSurface = new Graphic({
geometry: oceanSurfaceMesh,
symbol: {
type: "mesh-3d",
symbolLayers: [{
type: "fill"
}]
}
});
view.graphics.add(oceanSurface);
const cloudsSphere = Mesh.createSphere(new Point({
x: 0, y: -90, z: -(2 * R + offset)
}), {
size: 2 * (R + offset),
material: {
colorTexture: './clouds-nasa.png',
doubleSided: false
},
densificationFactor: 4
});
cloudsSphere.components[0].shading = "flat";
const clouds = new Graphic({
geometry: cloudsSphere,
symbol: {
type: "mesh-3d",
symbolLayers: [{ type: "fill" }]
}
});
view.graphics.add(clouds);
const extremesLayer = new GeoJSONLayer({
url: "extreme-points.geojson",
elevationInfo: {
mode: "absolute-height",
offset: offset
},
copyright: "Data from <a href=\"https://en.wikipedia.org/wiki/Extreme_points_of_Earth\" target=\"_blank\">Extreme points on Earth</a> Wikipedia article | <a href=\"https://visibleearth.nasa.gov/view.php?id=57747\" target=\"_blank\">Cloud image</a> from NASA Goddard Space Flight Center (image by Reto Stöckli) for the cloud layer",
renderer: {
type: "simple",
symbol: {
type: "point-3d",
symbolLayers: [{
type: "icon",
resource: { primitive: "circle" },
material: { color: [0, 0, 0, 0] },
outline: { color: [245, 99, 66, 1], size: 4 },
size: 10
}, {
type: "icon",
resource: { primitive: "circle" },
material: { color: [0, 0, 0, 0] },
outline: { color: [245, 99, 66, 1], size: 2 },
size: 30
}]
}
},
popupTemplate: {
title: "{name}",
content: `
<div class="popupImage">
<img src="{imageUrl}" alt="{imageCaption}"/>
</div>
<div class="popupImageCaption">{imageCaption}</div>
<div class="popupDescription">
<p class="info">
<span class="esri-icon-favorites"></span> {type}
</p>
<p class="info">
<span class="esri-icon-map-pin"></span> {location}
</p>
<p class="info">
<span class="esri-icon-documentation"></span> {facts}
</p>
</div>
<div class="popupCredits">
Sources: <a href="{sourceUrl}" target="_blank">{source}</a> released under <a href="{sourceCopyrightUrl}">{sourceCopyright}</a>, <a href="{imageCopyrightUrl}" target="_blank">{imageCopyright}</a>.
</div>
`
}
});
map.layers.add(extremesLayer);
document.getElementById("close-about").addEventListener("click", closeMenu);
document.getElementById("start-globe").addEventListener("click", function () {
closeMenu();
view.when(function () {
watchUtils.whenFalseOnce(view, "updating", rotate);
});
});
document.getElementById("container").addEventListener("click", function (e) {
if (e.target.id === "container") {
closeMenu();
view.when(function () {
watchUtils.whenFalseOnce(view, "updating", rotate);
});
}
});
function closeMenu() {
document.getElementById("container").style.display = "none";
view.container.style.filter = "blur(0px)";
}
let intro = true;
document.getElementById("about").addEventListener("click", function () {
document.getElementById("container").style.display = "flex";
view.container.style.filter = "blur(10px)";
if (intro) {
document.getElementById("show-about").classList.remove("hidden");
document.getElementById("show-intro").classList.add("hidden");
intro = false;
}
});
view.ui.add("about", "bottom-left");
function rotate() {
if (!view.interacting) {
const camera = view.camera.clone();
camera.position.longitude -= 0.2;
view.goTo(camera, { animate: false });
requestAnimationFrame(rotate);
}
}
});
</script>
</head>
<body>
<div id="viewDiv">
<div id="about">About this globe</div>
</div>
<div id="container">
<div id="introDiv">
<h1>The globe of extremes</h1>
<div id="show-intro">
<p> Where is the most distant point from land? What altitude does the highest permanent human settlement have?
Who was the first to reach the lowest point on Earth? Click on the orange icons on this globe to find out!
</p>
<button id="start-globe">Go to globe</button>
</div>
<div id="show-about" class="hidden">
<button id="close-about" class="esri-icon-close"></button>
<p>3D Globe created by <a href="https://www.esri.com/arcgis-blog/author/j_nelson/" target="_blank">John</a> and
<a href="https://www.esri.com/arcgis-blog/author/raluca_zurich/" target="_blank">Raluca</a> after getting
inspired by the <a href="https://www.half-earthproject.org/maps/" target="_blank">Half-Earth Project globe</a>, and <a href="https://www.fonterra.com/nz/en/campaign/from-here-to-everywhere.html#/home"
target="_blank">this awesome globe</a> and <a href="https://www.instagram.com/p/Bt8zyI-gsqW/"
target="_blank">this other awesome globe</a>. We used <a
href="https://developers.arcgis.com/javascript/" target="_blank">ArcGIS API for JavaScript</a> to create the interactive globe and <a href="https://pro.arcgis.com/"
target="_blank">ArcGIS Pro</a> to create the basemap. Many thanks to Arno Fiva, Christian Iten and Jesse van den Kieboom for the awesome feedback.</p>
<p>Read this <a href="https://www.esri.com/arcgis-blog/products/js-api-arcgis/3d-gis/interactive-3d-globe/" target="_blank">blog post</a> to find out how the globe was created. For the curious coders, here is the <a href="https://github.com/RalucaNicola/the-globe-of-extremes" target="_blank">Github repository</a>.</p>
</div>
</div>
</div>
</body>
</html>