-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·501 lines (457 loc) · 16.6 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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<!DOCTYPE html>
<html>
<head>
<title>Georgetown Travelers</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="//use.typekit.net/akq3qbf.js"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
<link rel="shortcut icon" href="img/favicon.ico" />
<link rel="stylesheet" href="css/screen.css" />
<link rel="stylesheet" href="css/main.css" />
<link rel="stylesheet" href="css/leaflet.css" />
<style type="text/css">
.leaflet-container{background-color:#c5e8ff;}
.info {
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;
background: white;
background: rgba(216,216,216,0.8);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
width: 250px
}
.info h4, h6 {
margin: 0 0 5px;
color: #011e41;
}
#mapid {
width: 80%;
height: 800px;
margin: auto;
}
.legend {
text-align: left;
line-height: 18px;
color: #555;
width: 120px;
}
.legend i {
width: 18px;
height: 18px;
float: left;
margin-right: 8px;
opacity: 0.7;
}
</style>
</head>
<body>
<header class="navbar">
<div class="container">
<div class="navbar-header pull-xs-left">
<a href="http://www.georgetown.edu/">
<span class="sr-only">Georgetown University</span>
<img src="img/georgetown-2x.png" alt="Georgetown University" class="hidden-sm-down full-logo">
<img src="img/georgetown-abbr-2x.png" width="40" height="28" alt="Georgetown University" class="hidden-md-up pull-md-left pull-sm-left pull-xs-left">
</a>
<h2 id="site-title"><a class="site-name" href="/travelers">Georgetown Travelers</a></h2>
</div>
<div class="pull-xs-right hidden-md-up">
<a type="button" class="btn btn-primary btn-sm toggle-nav navbar-toggler" data-toggle="offcanvas">☰</a>
</div>
</div>
</header>
<div class="container-fluid content" style="padding-top: 20px">
<p>Map of expected current travelers and past travelers from January 2016 through August 2016 within the GU community (use the radio buttons to switch between these two groups). The shade of each country represents community member concentration, while the series of markers indicate the number of terrorist attacks, World Risk Indices (a comprehensive measure of natural disaster risk provided by the <a href="http://weltrisikobericht.de/english/" target="_blank">WorldRiskReport</a>), and the presence of Zika virus (Zika data provided by <a href="http://www.cdc.gov/zika/geo/active-countries.html" target="_blank">CDC</a>). Click the markers for more details.</p>
<div id="mapid"></div>
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="https://npmcdn.com/leaflet@1.0.0-rc.3/dist/leaflet.js"></script>
<script type="text/javascript" src="js/world.js"></script>
<script type="text/javascript">
// create map
var map = L.map('mapid', {
scrollWheelZoom: false,
maxZoom: 18,
minZoom: 2,
}).setView([0, 0], 2);
// add layers
var baseMap = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWljaGFlbHJlbnppIiwiYSI6ImNpcm52ZWdhYTBhZG90N25renEzZzk0ZncifQ.8qAmgjXGFFrjdiFUYNGz3A', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="http://mapbox.com">Mapbox</a>',
id: 'mapbox.light',
})
baseMap.addTo(map);
// control that shows state info on hover
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;
};
info.update = function (props) {
this._div.innerHTML = '<h4>GU Travelers</h4>' + (props ?
'<b>' + props.name + '</b><br />' + props.people + ' expected current traveler(s)<br />' + props.peoplePast + ' traveler(s) from 1/2016-8/2016'
: 'Hover over a country to see the number of travelers');
};
info.addTo(map);
//icons
var icon1 = L.icon({
iconUrl: 'img/marker-icon-feb24c.png',
iconSize: [16, 26],
iconAnchor: [8, 26],
popupAnchor: [0, -20],
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
var icon2 = L.icon({
iconUrl: 'img/marker-icon-fd8d3c.png',
iconSize: [19, 31],
iconAnchor: [9.5, 31],
popupAnchor: [0, -25],
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
var icon3 = L.icon({
iconUrl: 'img/marker-icon-f03b20.png',
iconSize: [22, 36],
iconAnchor: [11, 36],
popupAnchor: [0, -30],
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
var icon4 = L.icon({
iconUrl: 'img/marker-icon-bd0026.png',
iconSize: [25, 41],
iconAnchor: [12.5, 41],
popupAnchor: [0, -35],
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
var riskIcon0 = L.icon({
iconUrl: 'img/riskicon0.png',
iconSize: [22, 36],
iconAnchor: [11, 36],
popupAnchor: [0, -30],
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
var riskIcon1 = L.icon({
iconUrl: 'img/riskicon1.png',
iconSize: [22, 36],
iconAnchor: [11, 36],
popupAnchor: [0, -30],
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
var riskIcon2 = L.icon({
iconUrl: 'img/riskicon2.png',
iconSize: [22, 36],
iconAnchor: [11, 36],
popupAnchor: [0, -30],
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
var riskIcon3 = L.icon({
iconUrl: 'img/riskicon3.png',
iconSize: [22, 36],
iconAnchor: [11, 36],
popupAnchor: [0, -30],
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
var riskIcon4 = L.icon({
iconUrl: 'img/riskicon4.png',
iconSize: [22, 36],
iconAnchor: [11, 36],
popupAnchor: [0, -30],
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
var riskIcon5 = L.icon({
iconUrl: 'img/riskicon5.png',
iconSize: [22, 36],
iconAnchor: [11, 36],
popupAnchor: [0, -30],
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
var zikaIcon = L.icon({
iconUrl: 'img/zikamarker.png',
iconSize: [22, 36],
iconAnchor: [11, 36],
popupAnchor: [0, -30],
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
// functions to style each area
function getColor(d) {
return d > 200 ? '#023858' :
d > 150 ? '#045a8d' :
d > 100 ? '#0570b0' :
d > 50 ? '#3690c0' :
d > 10 ? '#74a9cf' :
d > 0 ? '#a6bddb' :
'#FFEDA0';
}
function getIcon(d) {
return d > 10 ? icon4 :
d > 5 ? icon3 :
d > 1 ? icon2 :
d > 0 ? icon1 :
'#FFEDA0';
}
function getIconColor(d) {
return d > 10 ? '#BD0026' :
d > 5 ? '#F03B20' :
d > 1 ? '#FD8D3C' :
d > 0 ? '#FEB24C' :
'#FFEDA0';
}
function getRiskIcon(d) {
return d > 10.4 ? riskIcon5 :
d > 7.31 ? riskIcon4 :
d > 5.47 ? riskIcon3 :
d > 3.47 ? riskIcon2 :
d > 0.08 ? riskIcon1 :
d > 0 ? riskIcon0 :
'#FFFFFF';
}
function getRiskIconColor(d) {
return d > 10.4 ? '#d73027' :
d > 7.31 ? '#fc8d59' :
d > 5.47 ? '#fee08b' :
d > 3.47 ? '#d9ef8b' :
d > 0.08 ? '#91cf60' :
d > 0 ? '#1a9850' :
'#FFFFFF';
}
function style(feature) {
if(feature.properties.people > 0) {
return {
weight: 1,
opacity: 1,
color: 'white',
dashArray: '',
fillOpacity: 0.7,
fillColor: getColor(feature.properties.people),
}
}
else {
return {
weight: 0,
opacity: 0,
color: 'red',
dashArray: '',
fillOpacity: 0.0,
fillColor: getColor(feature.properties.people)
}
};
}
function stylePast(feature) {
if(feature.properties.peoplePast > 0) {
return {
weight: 1,
opacity: 1,
color: 'white',
dashArray: '',
fillOpacity: 0.7,
fillColor: getColor(feature.properties.peoplePast),
}
}
else {
return {
weight: 0,
opacity: 0,
color: 'red',
dashArray: '',
fillOpacity: 0.0,
fillColor: getColor(feature.properties.peoplePast)
}
};
}
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 1,
color: '#666',
dashArray: '',
fillOpacity: 0.7,
});
if (!L.Browser.ie && !L.Browser.opera) {
layer.bringToFront();
}
info.update(layer.feature.properties);
}
// functions to run over each geoJSON once it is called
var geojson, geojson2;
function resetHighlight(e) {
geojson.resetStyle(e.target);
info.update();
}
function resetHighlightPast(e) {
geojson2.resetStyle(e.target);
info.update();
}
function zoomToFeature(e) {
map.fitBounds(e.target.getBounds());
}
function onEachFeature(feature, layer) {
if(feature.properties.people >= 0) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
click: zoomToFeature
}).addTo(shapes);
var coordinate = feature.point;
if (feature.properties.attacks>0) {
var marker = L.marker(coordinate, {icon: getIcon(feature.properties.attacks)}).addTo(countries).bindPopup("<strong>" + feature.properties.name + ":</strong><br />" + feature.properties.attacks + " incident(s) since 2010, <br />" + feature.properties.people + " expected current community member(s)<br />" + feature.properties.peoplePast + " past community member(s)");
}
if (feature.riskIndex>5.46) {
var marker = L.marker(coordinate, {icon: getRiskIcon(feature.riskIndex)}).addTo(riskLayer).bindPopup("<strong>" + feature.properties.name + ":</strong><br />World Risk Index: " + feature.riskIndex + "%<br />" + feature.properties.people + " current community member(s)<br />" + feature.properties.peoplePast + " past community members");
}
if (feature.zika>0) {
var marker = L.marker(coordinate, {icon: zikaIcon}).addTo(health).bindPopup("<strong>" + feature.properties.name + ":</strong><br />World Risk Index: " + feature.riskIndex + "%<br />" + feature.properties.people + " current community member(s)<br />" + feature.properties.peoplePast + " past community members");
}
}
}
function onEachFeaturePast(feature, layer) {
if(feature.properties.peoplePast >= 0) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlightPast,
click: zoomToFeature
}).addTo(past);
var coordinate = feature.point;
if (feature.properties.attacks>0) {
var marker = L.marker(coordinate, {icon: getIcon(feature.properties.attacks)}).addTo(countries).bindPopup("<strong>" + feature.properties.name + ":</strong><br />" + feature.properties.attacks + " incident(s) since 2010, <br />" + feature.properties.people + " current community member(s)<br />" + feature.properties.peoplePast + " past community members");
}
if (feature.riskIndex>5.46) {
var marker = L.marker(coordinate, {icon: getRiskIcon(feature.riskIndex)}).addTo(riskLayer).bindPopup("<strong>" + feature.properties.name + ":</strong><br />World Risk Index: " + feature.riskIndex + "%<br />" + feature.properties.people + " current community member(s)<br />" + feature.properties.peoplePast + " past community members");
}
if (feature.zika>0) {
var marker = L.marker(coordinate, {icon: zikaIcon}).addTo(health).bindPopup("<strong>" + feature.properties.name + ":</strong><br />Confirmed cases of Zika<br />" + feature.properties.people + " current community member(s)<br />" + feature.properties.peoplePast + " past community members");
}
}
}
var shapes = new L.layerGroup();
var countries = new L.layerGroup();
var riskLayer = new L.layerGroup();
var past = new L.layerGroup();
var health = new L.layerGroup();
// call in geoJSON
geojson = L.geoJson(countriesData, {
style: style,
onEachFeature: onEachFeature
}).addTo(map);
geojson2 = L.geoJson(countriesData, {
style: stylePast,
onEachFeature: onEachFeaturePast
}).addTo(past);
map.attributionControl.addAttribution('World Risk Index data from <a target="_blank" href="http://weltrisikobericht.de/english/">World Risk Report</a>');
map.attributionControl.addAttribution('Zika data from <a target="_blank" href="http://www.cdc.gov/zika/geo/active-countries.html">CDC</a>');
// add legends
var legend = L.control({position: 'bottomleft'});
legend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'info legend'),
grades = [0, 10, 50, 100, 150, 200],
labels = [],
from, to;
for (var i = 0; i < grades.length; i++) {
from = grades[i] + 1;
to = grades[i + 1];
labels.push(
'<i style="background:' + getColor(from + 1) + '"></i> ' +
from + (to ? '–' + to : '+'));
}
div.innerHTML = '<h6 style="margin-bottom:1px"># Travelers</h6>' + labels.join('<br>');
return div;
};
legend.addTo(map);
var attackLegend = L.control({position: 'bottomright'});
attackLegend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'info legend attack'),
grades = [0, 1, 5, 10],
labels = [],
from, to;
for (var i = 0; i < grades.length; i++) {
if (i == 0) {
from = grades[i];
}
else {
from = grades[i] + 1;
}
to = grades[i + 1];
if (i==0) {
labels.push(
'<i style="background:' + getIconColor(from + 1) + '"></i> ' +
(from + 1));
}
else {
labels.push(
'<i style="background:' + getIconColor(from + 1) + '"></i> ' +
from + (to ? '–' + to : '+'));
}
}
div.innerHTML = '<h6 style="margin-bottom:1px"># Incidents</h6>' + labels.join('<br>');
return div;
};
attackLegend.addTo(map);
var riskLegend = L.control({position: 'bottomright'});
riskLegend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'info legend'),
grades = [5.47, 7.31, 10.4],
labels = [],
from, to;
for (var i = 0; i < grades.length; i++) {
from = grades[i];
to = grades[i + 1];
labels.push(
'<i style="background:' + getRiskIconColor(from + 1) + '"></i> ' +
from + (to ? '–' + to : '+'));
}
div.innerHTML = '<h6 style="margin-bottom:1px">World Risk Index (%)</h6>' + labels.join('<br>');
return div;
};
riskLegend.addTo(map);
shapes.addTo(map);
var baseLayers = {
"Expected Travelers": shapes,
"Past Travelers": past
};
var overlays = {
"Incidents": countries,
"World Risk Index": riskLayer,
"Zika": health
};
layerControl = L.control.layers(baseLayers, overlays, {position: 'topleft', collapsed: false}).addTo(map);
</script>
<p> </p>
<hr />
<div class="row" style="padding-bottom:1rem;">
<div class="col-md-6">
<p style="text-align:center"><strong>Expected travelers from 9/1/2016-12/31/2016</strong></p>
<img alt="Graph of expected current travelers by Country" src="img/top_future_travelers.png" />
</div>
<div class="col-md-6">
<p style="text-align:center"><strong>Travelers from 1/1/2016-8/31/2016</strong></p>
<img alt="Graph of past travelers by Country" src="img/top_past_travelers.png" />
</div>
</div>
<div class="row" style="padding-bottom:2rem;">
<div class="col-md-6">
<p style="text-align:center"><strong>Incidents by Country</strong></p>
<img alt="Graph of Incidents by Country" src="img/incidents-by-country.png" style="border:3" />
</div>
<div class="col-md-6">
<p style="text-align:center"><strong>Top World Risk Indices</strong></p>
<img alt="Graph of World Risk Index by Country" src="img/riskindex-by-country.png" />
<p style="text-align:center" class="small">Figures provided by <a target="_blank" href="http://weltrisikobericht.de/english/">World Risk Report</a></p>
</div>
</div>
</body>
</div>
<script type="text/javascript" src="js/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>
</body>
</html>