-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInternationalStudentViz.html
More file actions
362 lines (270 loc) · 14.2 KB
/
Copy pathInternationalStudentViz.html
File metadata and controls
362 lines (270 loc) · 14.2 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Use correct character set. -->
<meta charset="utf-8">
<!-- Tell IE to use the latest, best version. -->
<!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> -->
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>ODU Geo-Vis: Intl. Students</title>
<!-- Cesiumjs Library -->
<script src="https://cesiumjs.org/releases/1.20/Build/Cesium/Cesium.js"></script>
<!-- Load jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<!-- Load Bootstrapjs - Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!-- Load Bootstrapcss - Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- Color Scaling Script -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.1.1/chroma.min.js"></script>
<!-- Load Custom Style Sheet -->
<link name ="Stylee" rel="stylesheet" href="Stylee.css">
<!-- Load Cesium Widget Styling -->
<style>
@import url(https://cesiumjs.org/releases/1.20/Build/Cesium/Widgets/widgets.css);
html, body, #cesiumContainer {
position: fixed;
top: 0;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
z-index: -1;
}
</style>
<!-- Load Geovis Logo for Web Page Tab -->
<link rel="icon" type="image/png" href="Geovis_v4.png" sizes="96x96">
</head>
<!-- Runs the Function "displayData" in the js as soon as the page loads -->
<!-- Forces the user to view the default dataset on load (wont load a blank page) -->
<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="https://www.odu.edu/" target="_blank" class="animate">
<span class="desc animate">Old Dominion University</span>
<img src="ODUlogo.png" width="45" height="45" 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="45" height="45" 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="45" height="45" 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="Cesium.png" width="45" height="45" z-index="1000">
</a>
</li>
<!-- Logo & Link to meet the team (Replaces Credit Container @ Bottom) -->
<!-- <li>
<a href="https://cesiumjs.org/index.html" target="_blank" class="animate">
<span class="desc animate">Meet the team</span>
<span style="font-size:30px;cursor:pointer" width="75" height="75" z-index="1000" onclick="openNav()"><img src="crown.png" width="75" height="75" z-index="1000">; yo</span>
</a>
</li>
-->
</ul>
</nav>
<!-- Div containing Cesium Viewer -->
<div id="cesiumContainer"></div>
<!-- meet the team overlay material -->
<!-- *** end *** overlay material -->
<!-- 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">
<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>
<li>
<input type="radio" id="2016" onclick="displayData();" name="datayear" value=2016>
<label for="2016">2016</label>
<div class="check"></div>
</li>
</ul>
</div>
<div class="yearContainer">
<h3 style="font-size:8px;cursor:pointer" class="yearContainer">
<img src="yearicon.png" width="30" height="25"alt="year icon" />;
</h3>
</div>
<script type = "text/javascript">
//------- for radio button container toggle --------------
//var count = 0;
// $( ".yearContainer" ).on('click', function() {
// // event.preventDefault();
// $( ".radioContainer" ).toggle( "slide" );
// // $("ul").animate({slide: 'toggle'});
//
// });
$('.radioContainer').hide();
$(document).ready(function() {
$( ".yearContainer" ).on('click', function() {
var click = $(this).data('clicks');
//$( ".radioContainer" ).toggle( "slide" );
if (click) {
$('.radioContainer').show();
}else{
$('.radioContainer').hide();
};
$(this).data('clicks', !click);
});
});
// // Hide menu once we know its width
// $('.yearContainer').off('click').on('click', function() {
// var $radioContainer = $('.radioContainer');
// if ($radioContainer.is(':visible')) {
// // Slide away
// $radioContainer.animate({left: -($radioContainer.outerWidth() + 10)}, function() {
// $radioContainer.hide();
// });
// }
// else {
// // Slide in
// $radioContainer.show().animate({left: 0});
// }
// });
//
//
// 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', {
/* image options*/
imageryProvider : new Cesium.ArcGisMapServerImageryProvider({
/* street view */
//url : 'https://server.arcgisonline.com/arcgis/rest/services/ESRI_StreetMap_World_2D/MapServer'
/* satellite view */
// url : 'https://server.arcgisonline.com/arcgis/rest/services/ESRI_Imagery_World_2D/MapServer'
/* natgeo view */
url : 'https://server.arcgisonline.com/arcgis/rest/services/NatGeo_World_Map/MapServer'
/*street map*/
//url : 'https://server.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer'
/*topo map*/
//url : 'https://server.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer'
/*shaded relief*/
// url : 'https://server.arcgisonline.com/arcgis/rest/services/World_Shaded_Relief/MapServer'
}),
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('StudentCountsLatest.json',{
stroke: Cesium.Color.LIGHTBLUE,
fill: Cesium.Color.PINK.withAlpha(0.01),
strokeWidth: 0.001
});
// Sets up viewer to add datasource after .then is complete
promise.then(function(dataSource) {
viewer.dataSources.add(dataSource);
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
var year,yearObject;
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
Object.size = function(obj) {
var size = 0, key;
for (key in obj) {
year = dataset;
yearObject = "Count"+dataset;
if(key == yearObject){
if (dataset == year){
studentCnt = entity.properties[key];
}
}
}
return size;
};
var size = Object.size(entity.properties);
// 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).' + ' There was ' + String(studentCnt) + ' distance learning student from ' + entity.properties.NAME + ' attending Old Dominion University in the ' + String(dataset) + ' academic year.' ];
} 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.'];
}
var pinBuilder = new Cesium.PinBuilder(); // ODU Pin
var bluePin = viewer.entities.add({
name : '433 Gornto Center, Old Dominion University, VA 23529',
position : Cesium.Cartesian3.fromDegrees(-76.3040051, 36.8840145), // gornto lat long
billboard : {
image : pinBuilder.fromText('ODU', Cesium.Color.STEELBLUE, 58).toDataURL(),
verticalOrigin : Cesium.VerticalOrigin.BOTTOM
}
});
//Since some of the pins are created asynchronously, wait for them all to load before zooming/
Cesium.when.all([bluePin], function(pins){
});
} // end of polygon attribute loop
}); // end of .then function --> loads json
}; // end of display data function
</script>
</body>
</html>