-
Notifications
You must be signed in to change notification settings - Fork 50
/
heatmap-bkp.html
566 lines (492 loc) · 17.7 KB
/
heatmap-bkp.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
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Bo Zhao">
<title>Damron Guide: Seattle</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
<link href="https://fonts.googleapis.com/css?family=Titillium+Web" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Oswald&display=swap" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.6.14/c3.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/heatmap.css">
<!-- <link rel="stylesheet" href="css/jqcloud.css"> -->
<link rel="icon" href="img/favicon.ico" type="image/x-icon" />
<script src="js/d3.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.6.14/c3.min.js"></script>
<script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js"></script>
<script src="js/leaflet.heat.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.3.4/chroma.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<header>
<div class="collapse bg-dark" id="navbarHeader">
<div class="container-fluid">
<div class="row">
<div class="col-sm-8 col-md-7 py-4">
<h4 class="text-white">About</h4>
<p class="text-muted">This website utilizes online maps to
visually explore Damron’s Travel Guide.</p>
<p class="text-muted">The guidebook’s author, Bob Damron, gave gay readers hope by fleshing out worlds that would’ve otherwise remained unknowable. His list confirmed that a gay America existed and that within this quasi-nation, many
smaller gay Americas proliferated. Each one was bound by unique affinities whose siren songs went muffled. With tact, Damron amplified these calls. His guidebook told where to find doorways flowing towards danger and joyful possibility.
It pinpointed thresholds leading to family, community, sex, and love.</p>
</div>
<div class="col-sm-4 offset-md-1 py-4">
<h4 class="text-white">Contact</h4>
<ul class="list-unstyled">
<li><a href="#" class="text-white">Follow on Twitter</a></li>
<li><a href="#" class="text-white">Like on Facebook</a></li>
<li><a href="#" class="text-white">Email me</a></li>
</ul>
</div>
</div>
<div class="navbar-expand-md navbar-dark bg-dark shadow-sm">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="seattle.html">Seattle</a>
</li>
<li class="nav-item">
<a class="nav-link" href="atlanta.html">Atlanta</a>
</li>
<li class="nav-item">
<a class="nav-link" href="omaha.html">Omaha</a>
</li>
<li class="nav-item">
<a class="nav-link" href="worcester.html">Worcester</a>
</li>
</ul>
</div>
</div>
</div>
<div class="navbar navbar-dark bg-dark shadow-sm">
<div class="container-fluid d-flex justify-content-between">
<a href="index.html" class="navbar-brand d-flex align-items-center">
<img src="img/logo.png" class="img-responsive" height="30"></img>
<strong> COVID-19 HeatMap (beta) </strong>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
</header>
<main>
<div class="loader"></div>
<div id="upper_panel" class="d-flex align-items-start flex-column">
<!-- <span id="year">COVID-19 </span> -->
<div id="timeline-chart"></div>
<div id="mapToggle" class="col-md-5 align-items-center">
<span id="mapType">Heatmap</span>
<label id="hmSwitcher" class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
<div id="hmLegendContainer"></div>
</div>
</div>
<!-- <div id="info" class="d-flex flex-column">
<h4>Seattle <i class="showFrontPage fas fa-question-circle"></i></h4>
<p id="caseDesc"><img src="img/seattle2.png" align="left" style="width:70px; margin-right:10px"></img> This online map visualizes the spatial pattern and temporal changes of the LGBT related places in Seattle. The map was created and geo-referenced by the data
digitalized from Damron's Travel Guide, and the charts below was made by simulated datasets.
</p>
<div id="cloud"></div>
<div id="fChart"></div>
<div id="tChart"></div>
</div> -->
<div id="map"></div>
</main>
<!-- Modal -->
<!-- <div id="disclaimer" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document" style="width:1250px!important">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Help</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<img class="img-fluid" src="img/help.png"></img>
</div>
<div class="modal-footer">
<div class="col-md-10">
<span id="mapType">Don't show this info again.</span>
<label id="nextTimeSwitcher" class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
</div>
<button id="disclaimer-close" type="button" class="btn btn-primary col-md-2">close</button>
</div>
</div>
</div>
</div> -->
<script>
$(window).ready(function() {
$('.loader').fadeOut("slow");
$("#nextTimeSwitcher input").on("click", function() {
if ($("#nextTimeSwitcher input:checked").val() === "on") {
localStorage.setItem('popState', 'shown');
} else {
localStorage.setItem('popState', 'notShown');
}
})
if (localStorage.getItem('popState') != 'shown') {
console.log("show disclaimer");
$('#disclaimer').modal('show');
} else {
console.log("hide disclaimer");
$('#disclaimer').modal('hide');
}
$('#disclaimer-close').click(function(e) // You are clicking the close button
{
$('#disclaimer').fadeOut(); // Now the pop up is hiden.
$('#disclaimer').modal('hide');
});
});
$(".showFrontPage").on("click", function() {
$('#disclaimer').modal('show');
localStorage.setItem('popState', 'notShown');
})
var mymap = L.map('map', {
center: [37.609, -100],
zoomControl: false,
zoom: 5,
maxZoom: 18,
minZoom: 2
});
new L.Control.Zoom({
position: 'topright'
}).addTo(mymap);
// var dark = L.tileLayer('http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}@2x.png').addTo(mymap);
var grayscale = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}@2x.png').addTo(mymap);
var streets = L.tileLayer('http://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}@2x.png');
var satellite = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}@2x');
var baseLayers = {
// 'Dark': dark,
'Grayscale': grayscale,
'Streets': streets,
'Satellite': satellite
}
var Group = L.layerGroup().addTo(mymap);
// var wGroup = L.layerGroup().addTo(mymap);
var mLayers, wLayers;
var chart, fChart;
var heatmapFlag = false;
var colorscheme = chroma.scale('OrRd').colors(10).reverse(); //colorscheme = chroma.scale('OrRd').colors(5);
var Heatmap = L.heatLayer([], {
minOpacity: 0.35,
// max: 10,
// radius: 12,
// blur: 10,
// gradient: {
// 0.1: "rgb(0,0,255)",
// 0.15: "rgb(0,255,255)",
// 0.16: "rgb(0,255,0)",
// 0.20: "rgb(255,255,0)",
// 0.30: "rgb(255,0,0)"
// }
}).addTo(mymap);
var zoningColors = chroma.scale('Set2').mode('lch').colors(11);
var acsColors = chroma.scale('YlOrRd').colors(8);
// var overlays = {
// "<i class='fas fa-circle fa-xs men'></i> <span style='color: rgb(0,40,255)'>Men</span>": mGroup,
// "<i class='fas fa-circle fa-xs women'></i> <span style='color: rgb(255,0,255)'>Women</span>": wGroup,
// "<span>Place Names</span>": L.tileLayer('https://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}{r}@2x.png').addTo(mymap)
// }
//
// L.control.layers(baseLayers, overlays, {
// collapsed: false,
// position: 'topright'
// }).addTo(mymap);
var dates = {}
Promise.all([d3.csv("assets/cases-heatmap.csv")]).then(function(datasets) {
datasets[0].forEach(function(d) {
if (dates[d.date] == undefined) {
dates[d.date] = [
[d.lat, d.lng]
]
} else {
dates[d.date].push([d.lat, d.lng]);
}
})
var t = ["t"],
pop = ["pop"];
Object.keys(dates).forEach(function(d) {
t.push(d);
pop.push(dates[d].length);
});
var a = 3;
chart = c3.generate({
size: {
height: 80,
width: 480
},
data: {
x: "t",
columns: [t, pop],
// onmouseover: update,
type: 'line',
// labels: false,
colors: {
"pop": 'rgba(0, 40, 255, .6)'
}
},
axis: {
x: {
type: "category",
tick: {
format: "%b %d",
centered: true,
fit: true,
// count: 4,
rotate: -60,
multiline: false
}
},
y: {
label: {
text: 'Cases',
position: 'outer-middle'
},
min: 0,
padding: {
bottom: 0
},
// tick: {
// format: d3locale.format(",")
// },
type: 'linear'
}
},
// area: {
// zerobased: true
// },
tooltip: {
show: false
},
legend: {
show: false
},
point: {
r: 3,
focus: {
expand: {
r: 10
}
}
},
bindto: "#timeline-chart"
});
//
// datasets[0].forEach(function(d) {
// //console.log(d.id)
// // L.marker([parseFloat(d.lat), parseFloat(d.lng)]).bindPopup("<b>" + d.no + "</b> <p>" + d.note + " identified on " + d.date + ", <a href='https://" + d.reference + "' target='_blank'>" + d.reference + "</a>.</p>").addTo(Group);
//
// Heatmap.addLatLng(new L.latLng(d.lat, d.lng));
// })
// $.each(mLayers[d.x]._layers, function(i, d) {
// mHeatmap.addLatLng(new L.latLng(d.feature.geometry.coordinates[1], d.feature.geometry.coordinates[0]));
// });
// wLayers[2012].addTo(wGroup);
// mymap.on('overlayadd', function(eventlayer) {
// if (eventlayer.layer == wGroup) {
//
// chart.load({
// columns: [wPop]
// });
//
// fChart.load({
// columns: [
// ["Women", Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1]
// ]
// });
//
// tChart.load({
// columns: [
// ["Women", Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1]
// ]
// });
// }
//
// if (eventlayer.layer == mGroup) {
// chart.load({
// columns: [mPop]
// });
//
// fChart.load({
// columns: [
// ["Men", Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1]
// ]
// });
//
// tChart.load({
// columns: [
// ["Men", Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1]
// ]
// });
// }
//
// });
// mymap.on('overlayremove', function(eventlayer) {
// if (eventlayer.layer == wGroup) {
//
// chart.unload({
// ids: ['# Women']
// });
//
// fChart.unload({
// ids: ['Women']
// });
// tChart.unload({
// ids: ['Women']
// });
//
// }
//
// if (eventlayer.layer == mGroup) {
//
// chart.unload({
// ids: ['# Men']
// });
//
// fChart.unload({
// ids: ['Men']
// });
//
// tChart.unload({
// ids: ['Men']
// });
//
// }
//
// });
});
$(".leaflet-control-attribution")
.css("bottom", "60px")
// .css("right", "120px")
// .css("font-size", "14px")
.css("background-color", "transparent")
.html("");
// $("#hmSwitcher input").on("click", function() {
// if ($("#hmSwitcher input:checked").val() === "on") {
// heatmapFlag = true;
// var colors = chroma.scale('Spectral').domain([0, 50]).colors(50); //colors = chroma.scale('OrRd').colors(5);
// $("#hmLegendContainer").append("<div id='hmLegend'> </div>")
// for (var j = 0; j < colors.length; j++) {
// $("#hmLegend").append("<i style='background: " + colors[j] + " ; opacity:0.9'></i>");
// }
// $("#hmLegend").parent().append("<span>more</span>");
// $("#hmLegend").parent().append(" <span>less</span>");
//
// } else {
// heatmapFlag = false;
// $("#hmLegendContainer").empty();
// }
//
// update({
// x: +$("#year").text()
// });
//
// });
//
//
// function update(d) {
// $("#year").text(d.x);
//
// mGroup.clearLayers();
// wGroup.clearLayers();
// mHeatmap.setLatLngs([]);
// wHeatmap.setLatLngs([]);
//
//
//
// if (mymap.hasLayer(mGroup)) {
// if (!heatmapFlag) {
// mLayers[d.x].addTo(mGroup);
// } else {
// $.each(mLayers[d.x]._layers, function(i, d) {
// mHeatmap.addLatLng(new L.latLng(d.feature.geometry.coordinates[1], d.feature.geometry.coordinates[0]));
// });
// }
//
//
//
//
// fChart.load({
// columns: [
// ["Men", Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1]
// ]
// });
//
//
// tChart.load({
// columns: [
// ["Men", Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1]
// ]
// });
//
//
//
// }
//
//
//
// if (mymap.hasLayer(wGroup)) {
//
// if (d.x == 1965 || d.x == 1975 || d.x == 1983) {
// fChart.load({
// columns: [
// ["Women", 0, 0, 0, 0]
// ]
// });
//
// tChart.load({
// columns: [
// ["Women", 0, 0, 0, 0, 0]
// ]
// });
//
// } else {
//
// if (!heatmapFlag) {
// wLayers[d.x].addTo(wGroup);
// } else {
// $.each(wLayers[d.x]._layers, function(i, d) {
// wHeatmap.addLatLng(new L.latLng(d.feature.geometry.coordinates[1], d.feature.geometry.coordinates[0]));
// });
// }
//
//
// fChart.load({
// columns: [
// ["Women", Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1, Math.floor(Math.random() * 40) + 1]
// ]
// });
//
//
// tChart.load({
// columns: [
// ["Women", Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1, Math.floor(Math.random() * 25) + 1]
// ]
// });
//
// }
//
//
// }
//
//
//
//
//
// }
</script>
</body>
</html>