-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesri.html
296 lines (249 loc) · 11.6 KB
/
esri.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>ODU Geo-Vis: Intl. Students</title>
<!-- Load Custom Style Sheet -->
<link name ="Stylee" rel="stylesheet" href="Stylee.css">
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<!-- Load Geovis Logo for Web Page Tab -->
<link rel="icon" type="image/png" href="Geovis_v4.png" sizes="96x96">
<link rel="stylesheet" href="https://js.arcgis.com/4.3/esri/css/main.css">
<script src="https://js.arcgis.com/4.3/"></script>
<script>
require([
"esri/Map",
"esri/views/SceneView",
"esri/layers/SceneLayer",
"esri/renderers/SimpleRenderer",
"esri/symbols/PointSymbol3D",
"esri/symbols/IconSymbol3DLayer",
"dojo/domReady!"
], function(Map, SceneView, SceneLayer, SimpleRenderer, PointSymbol3D,
IconSymbol3DLayer) {
// setup the renderer with size and color visual variables
var renderer = new SimpleRenderer({
symbol: new PointSymbol3D({
symbolLayers: [new IconSymbol3DLayer()]
}),
visualVariables: [{
// size each icon based on the airport's elevation
type: "size",
field: "elevation_ft",
stops: [
{
value: 0,
size: 2
},
{
value: 15000,
size: 35
}]
}, {
// shade each airport a different color based on its type
type: "color",
field: "type_airport",
stops: [{
value: 1,
color: [252, 12, 245]
},
{
value: 3,
color: [83, 0, 244]
},
{
value: 7,
color: [4, 245, 248]
}]
}]
});
// Create SceneLayer from a Scene Service URL
var sceneLayer = new SceneLayer({
url: "http://tiles.arcgis.com/tiles/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Airports_PointSceneLayer/SceneServer/layers/0",
renderer: renderer // Set the renderer to sceneLayer
});
// Create Map
var map = new Map({
basemap: "dark-gray",
layers: [sceneLayer]
});
// Create the SceneView
var view = new SceneView({
container: "viewDiv",
map: map,
});
});
</script>
</head>
<!--
<body>
<div id="viewDiv"></div>
</body>
-->
<body onload="displayData();">
<!-- Div containing animated navbar -->
<nav class="navbar navbar-fixed-left navbar-minimal animate" role="navigation">
<div class="navbar-toggler animate">
<span class="menu-icon"></span>
</div>
<ul class="navbar-menu animate">
<li>
<!-- Logo & Link to to ODU Homepage -->
<a href="http://www.odu.edu/" target="_blank" class="animate">
<span class="desc animate">Old Dominion University</span>
<img src="ODUlogo.png" width="75" height="75" z-index="1000">
</a>
</li>
<li>
<!-- Logo & Link to to ODU Online Homepage -->
<a href="https://online.odu.edu/" target="_blank" class="animate">
<span class="desc animate">Old Dominion University - Distance Learning</span>
<img src="OduOnlineLogoedit.png" width="75" height="75" z-index="1000">
</a>
</li>
<li>
<!-- Logo & Link to to ODU GIS/Geovis Homepage -->
<a href="https://www.odu.edu/facultystaff/research/resources/computing/gis" target="_blank" class="animate">
<span class="desc animate">Old Dominion University - Center for Geospatial & Visualization Computing</span>
<img src="Geovis_v4.png" width="75" height="75" z-index="1000">
</a>
</li>
<li>
<!-- Logo & Link to to Cesium (Replaces Credit Container @ Bottom) -->
<a href="https://cesiumjs.org/index.html" target="_blank" class="animate">
<span class="desc animate">Cesium.js</span>
<img src="CesiumEdit.png" width="75" height="75" z-index="1000">
</a>
</li>
</ul>
</nav>
<!-- Div containing Cesium Viewer -->
<div id="cesiumContainer"></div>
<!-- Div containing Radio Buttons - Use to switch between academic years -->
<!-- 2013 is the default (see "Checked") - onclick fires the function "displayData" in js -->
<div class="radioContainer">
<h2>Academic Year:</h2>
<ul>
<li>
<input type="radio" id="2013" onclick="displayData();" name="datayear" value=2013 checked="checked">
<label for="2013">2013</label>
<div class="check"></div>
</li>
<li>
<input type="radio" id="2014" onclick="displayData();" name="datayear" value=2014>
<label for="2014">2014</label>
<div class="check"></div>
</li>
<li>
<input type="radio" id="2015" onclick="displayData();" name="datayear" value=2015>
<label for="2015">2015</label>
<div class="check"></div>
</li>
</ul>
</div>
<script type = "text/javascript">
// Uses Jquery to control the animation of the navbar
$('.navbar-toggler').on('click', function(event) {
event.preventDefault();
$(this).closest('.navbar-minimal').toggleClass('open');
})
// Creates the Cesium Viewer Box
var viewer = new Cesium.Viewer('cesiumContainer', {
baseLayerPicker : false, //turns off the options to switch between imagery tiles
timeline : false, //turns off bottom timeline toolbars
skyAtsmophere : false, //turns off the blue glow around the globe
globe : false, //turns off the globe visability
animation : false, //turns off the clock toolbar
geocoder : false, //turns off the address search function
vrButton : true //turns on the stereoscopic view option button
});
// Removes credit container at the bottom of the page (replaced in navbar)
viewer.cesiumWidget.creditContainer.parentElement.style.display = 'none';
// Forces Cesium to wait before loading its preset style sheet for the info box pop up, then forces injection of style from our own .ccs sheet
setTimeout(function(){
var cssLink = document.createElement("link");
cssLink.href= 'Stylee.css';
cssLink.rel = "stylesheet";
cssLink.type = "text/css";
viewer.infoBox.frame.contentDocument.head.appendChild(cssLink);
},5000);
// The function called every time a radio button is pressed to switch between data years
function displayData() {
// Returns the parameters of the radio button toolbar
var radioYears = document.getElementsByName('datayear');
// Searches radio button values, then stops loop if "Checked" = true
// Returns the academic year to be used in data rendering
for(var b = 0; b< radioYears.length; b++) {
if(radioYears[b].checked) {
dataset = radioYears[b].value;
break;
}
};
// Removes all previously rendered data
viewer.dataSources.removeAll();
// Loads Geojson polygons after the .then function is completed
var promise = Cesium.GeoJsonDataSource.load('InternationalStudentCount.json');
// Sets up viewer to add datasource after .then is complete
promise.then(function(dataSource) {
viewer.dataSources.add(dataSource);
// Get the array of entities from Geojson File
var entities = dataSource.entities.values;
// Loop that goes through each entity (country polygon) in the geojson file and provides them charactaristics based on the number of students for the given academic year
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
// Gets the correct student count corresponding to the chosen data year from the dataset based on the checked radio button
if (dataset === '2013'){
studentCnt = entity.properties.Count2013;
} else if (dataset === '2014'){
studentCnt = entity.properties.Count2014;
} else {
studentCnt = entity.properties.Count2015;
};
// As height is in meters, extrusion must be multiplied by a factor in order to be noticable - set base thickness of extrusion as 50,000 m (w/ 0 students)
if (studentCnt == 0) {
height = 50000;
// Heights are relatively scaled (otherwise china & india are touching the moon)
} else {
height = 75000 + ((studentCnt / 155) * 950000);
}
// Sets extrusion height
entity.polygon.extrudedHeight = height;
// Loop sets onclick descriptions of individual countries
if (entity.properties.NAME == 'United States') {
entity.description = ['The United States is home to Old Dominion University: Located in the City of Norfolk, Virginia - Old Dominion University is a dynamic public research institution that serves its students and enriches the Commonwealth of Virginia, the nation and the world through rigorous academic programs, strategic partnerships, and active civic engagement.'];
} else if (studentCnt === 0) {
entity.description = 'There were no distance learning students from ' + entity.properties.NAME + ' attending Old Dominion University in the ' + String(dataset) + ' academic year.';
} else if (studentCnt ===1) {
entity.description = ['There was ' + String(studentCnt) + ' distance learning student from ' + entity.properties.NAME + ' attending Old Dominion University in the ' + String(dataset) + ' academic year.'];
} else {
entity.description = ['There were ' + String(studentCnt) + ' distance learning students from ' + entity.properties.NAME + ' attending Old Dominion University in the ' + String(dataset) + ' academic year.'];
}
// Creates a color scale between the two chosen colors based on the domains given
var scale = chroma.scale(['#426a8a','#4785b8']).domain([1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]);
// If there are no dis students, color is grey
if (studentCnt === 0) {
ecolor = '#6d7378';
// Else, color var is set from color scale by student count
} else {
ecolor = scale(studentCnt).hex();
}
// Sets color of polygon
entity.polygon.material = Cesium.Color.fromCssColorString(ecolor);
//Remove the polygon outlines (they look terrible)
entity.polygon.outline = false;
} // end of polygon attribute loop
}); // end of .then function --> loads json
}; // end of display data function
</script>
</body>
</html>