-
Notifications
You must be signed in to change notification settings - Fork 1
/
warmingAsElevation.html
272 lines (239 loc) · 7.78 KB
/
warmingAsElevation.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
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>
Warming of the Arctic by 2060
</title>
<link
rel="stylesheet"
href="https://js.arcgis.com/4.22/esri/themes/dark/main.css"
/>
<script src="https://js.arcgis.com/4.23/"></script>
<script>
require([
"esri/Map",
"esri/views/SceneView",
"esri/layers/ElevationLayer",
"esri/layers/BaseElevationLayer",
"esri/layers/VectorTileLayer",
"esri/Basemap",
"esri/layers/TileLayer",
"esri/widgets/Legend",
"esri/widgets/Home",
"esri/views/3d/environment/VirtualLighting"
], (
Map,
SceneView,
ElevationLayer,
BaseElevationLayer,
VectorTileLayer,
Basemap,
TileLayer,
Legend,
Home,
VirtualLighting
) => {
//////////////////////////////////////////////
//
// Create a subclass of BaseElevationLayer
//
/////////////////////////////////////////////
const ExaggeratedElevationLayer = BaseElevationLayer.createSubclass({
// Add an exaggeration property whose value will be used
// to multiply the elevations at each tile by a specified
// factor. In this case terrain will render 100x the actual elevation.
properties: {
exaggeration: 250000
},
// The load() method is called when the layer is added to the map
// prior to it being rendered in the view.
load: function () {
// elevation values
this._elevation = new ElevationLayer({
url: "https://tiles.arcgis.com/tiles/tWF28TdwCm3ZaV7m/arcgis/rest/services/diff_Layer_2060_elevation/ImageServer"
});
// wait for the elevation layer to load before resolving load()
this.addResolvingPromise(
this._elevation.load().then(() => {
// get tileInfo, spatialReference and fullExtent from the elevation service
// this is required for elevation services with a custom spatialReference
this.tileInfo = this._elevation.tileInfo;
this.spatialReference = this._elevation.spatialReference;
this.fullExtent = this._elevation.fullExtent;
})
);
return this;
},
// Fetches the tile(s) visible in the view
fetchTile: function (level, row, col, options) {
// calls fetchTile() on the elevationlayer for the tiles
// visible in the view
return this._elevation.fetchTile(level, row, col, options).then(
function (data) {
const exaggeration = this.exaggeration;
// `data` is an object that contains the
// the width and the height of the tile in pixels,
// and the values of each pixel
for (let i = 0; i < data.values.length; i++) {
// Multiply the given pixel value
// by the exaggeration value
data.values[i] = data.values[i] * exaggeration;
}
return data;
}.bind(this)
);
}
});
const basemap = new Basemap({
baseLayers: [
new TileLayer({
url: "https://tiles.arcgis.com/tiles/tWF28TdwCm3ZaV7m/arcgis/rest/services/diff_Layer_2060_color_3/MapServer"
})
]
});
const elevationLayer = new ExaggeratedElevationLayer();
// Add the countries vector tile layer
const vtlLayer = new VectorTileLayer({
url: "https://vectortileservices.arcgis.com/tWF28TdwCm3ZaV7m/arcgis/rest/services/countries_w_no_attributes/VectorTileServer"
});
// Add the diff 2060 tile layer
const diffLayer2060 = new TileLayer({
url: "https://tiles.arcgis.com/tiles/tWF28TdwCm3ZaV7m/arcgis/rest/services/diff_Layer_2060_color_3/MapServer"
});
// Add the exaggerated elevation layer to the map's ground
// in place of the default world elevation service
const map = new Map({
//basemap: basemap,
ground: {
layers: [elevationLayer]
},
layers: [diffLayer2060, vtlLayer],
});
const view = new SceneView({
container: "viewDiv",
map: map,
alphaCompositingEnabled: true,
qualityProfile: "high",
camera: {
position: [-55.039, 14.948, 30000000],
heading: 2.03,
tilt: 0.13
},
environment: {
background: {
type: "color",
//color: [255, 252, 244, 0]
color: '#000000'
},
starsEnabled: true,
atmosphereEnabled: false,
lighting: {
//directShadowsEnabled: false,
//date: "Sun Jun 23 2019 19:19:18 GMT+0200 (Central European Summer Time)"
type: "virtual"
}
},
constraints: {
altitude: {
min: 5000000,
max: 500000000
}
},
popup: {
dockEnabled: true,
dockOptions: {
position: "top-right",
breakpoint: false,
buttonEnabled: false
},
collapseEnabled: false
},
highlightOptions: {
color: [255, 255, 255],
haloOpacity: 0.5
}
});
let exaggerated = true;
document
.getElementById("exaggerate")
.addEventListener("click", (event) => {
if (exaggerated) {
map.ground = "world-elevation";
event.target.innerHTML = "Enable Scaling";
exaggerated = false;
} else {
map.ground = {
layers: [elevationLayer]
};
event.target.innerHTML = "Disable Scaling";
exaggerated = true;
}
});
view.ui.add("legend", "bottom-right");
view.environment.lighting = {
type: "virtual",
directShadowsEnabled: true // autocasts as new VirtualLighting({ directShadowsEnabled: true })
}
const homeBtn = new Home({
view: view
});
view.ui.add(homeBtn, "top-left");
});
</script>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
body {
background: radial-gradient(#12bff2, #0269a1);
//background: radial-gradient(#12bff2, #000000);
}
#viewDiv canvas {
filter: saturate(1.2) drop-shadow(0 0 20px white);
}
.buttons {
position: absolute;
top: 10px;
left: 0;
right: 0;
text-align: center;
}
.esri-button {
display: inline;
max-width: 200px;
background: #000000;
color: white;
}
#legend {
background-color: #000000;
padding: 1em;
}
.legend-title {
margin-top: 0;
font-size: 1.2em;
font-weight: bold;
color: white;
}
</style>
</head>
<body>
<div id="viewDiv">
<div id="legend">
<p class="legend-title"> Disproportionate Warming of the Arctic</p>
<img width=300 src="https://gfiske.github.io/ArcticMaps/RCP8_3_Globes_legend_for_web.png" alt="temperature legend">
</div>
</div>
<div class="buttons">
<button id="exaggerate" class="esri-button">Disable Scaling</button>
</div>
</body>
</html>