-
Notifications
You must be signed in to change notification settings - Fork 1
/
map.js
1189 lines (1082 loc) · 52.4 KB
/
map.js
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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// required variables DO NOT REMOVE
var props, header, content, titleName, headerClass;
var map;
//define search groups for each layer that will be searchable
var cntySearch = [];
var mcdSearch = [];
//declare boundary of region
var oLat = 39.97, oLng = -75.16, zLevel = 9;
// variables to use in click/mouseover/mouseout functions
var selected;
var opacity_layer;
var fillOpacityValue = .9;
$(document).ready(function() {
// $("#disModal").modal("show");
});
$('#mapdata-btn').click(function (e) {
e.preventDefault()
$('.cat-desc').hide();
$('.btn-group a[href="#mapdata-main"]').tab('show') // Select tab by name
});
$('#mapchart-btn').click(function (e) {
e.preventDefault()
$('.cat-desc').show();
$('.btn-group a[href="#mapchart-main"]').tab('show') // Select tab by name
});
$('.nav-tabs li a').click( function(e) {
history.pushState( null, null, $(this).attr('href') );
});
function legendraw(element) {
$("#EXTODModal").modal("show");
}
// this is Map Legend modal
function legendraw5(element) {
$("#rateModal").modal("show");
}
function myHandler(){
EXTODdraw(myHandler.caller.arguments[0].target.id);
// alert(myHandler.caller.arguments[0].target.id)
}
function EXTODdraw(value) {
$('#EXTODModal').one('shown.bs.modal', function() {
$('#EXTODTabs a[data-value="#' + value + '"]').tab('show'); }).modal('show');
}
var DVRPC = L.geoJson(null, {
style: {
color: 'rgb(140,140,140)',
weight: 3,
fill: false,
clickable: false
},
onEachFeature: function (feature, layer){
cntySearch.push({
name: layer.feature.properties.NAME,
source: "DVRPC",
id: L.stamp(layer),
bounds: layer.getBounds()
});
}
});
$.getJSON("data/cnty.js", function(data) {
DVRPC.addData(data);
});
var MCD = L.geoJson(null, {
style: {
color: '#939393',
weight: 1.5,
opacity:.85,
fill: false,
clickable: false
},
onEachFeature: function (feature, layer){
mcdSearch.push({
name: layer.feature.properties.MUN_NAME,
source: "MCD",
id: L.stamp(layer),
bounds: layer.getBounds()
});
}
});
$.getJSON("data/mcd.js", function(data) {
MCD.addData(data);
});
var getParameterByName = function(name) {
var match = RegExp('[?&]' + name + '=([^&]*)')
.exec(window.location.search);
return match ?
decodeURIComponent(match[1].replace(/\+/g, ' '))
: null;
}
currentLayer = getParameterByName("l") || "IPD_Score";
var getIMDColor = function(value) {
layer = currentLayer || "IPD_Score";
var series = {
"IPD_Score": {
"breaks": [34,30,27,24,21,19,17,15,13,9],
"colors": ['#00000','#081d58','#253494','#225ea8','#1d91c0','#41b6c4','#7fcdbb','#c7e9b4','#edf8b1','#ffffd9']
},
"Y_Score": {
"breaks": [4,3,2,1,0],
"colors": ['#00000','#253494','#2c7fb8','#41b6c4','#a1dab4']
},
"OA_Score": {
"breaks": [4,3,2,1,0],
"colors": ['#00000','#253494','#2c7fb8','#41b6c4','#a1dab4']
},
"F_Score": {
"breaks": [4,3,2,1,0],
"colors": ['#00000','#253494','#2c7fb8','#41b6c4','#a1dab4']
},
"RM_Score": {
"breaks": [4,3,2,1,0],
"colors": ['#00000','#253494','#2c7fb8','#41b6c4','#a1dab4']
},
"EM_Score": {
"breaks": [4,3,2,1,0],
"colors": ['#00000','#253494','#2c7fb8','#41b6c4','#a1dab4']
},
"FB_Score": {
"breaks": [4,3,2,1,0],
"colors": ['#00000','#253494','#2c7fb8','#41b6c4','#a1dab4']
},
"LEP_Score": {
"breaks": [4,3,2,1,0],
"colors": ['#00000','#253494','#2c7fb8','#41b6c4','#a1dab4']
},
"D_Score": {
"breaks": [4,3,2,1,0],
"colors": ['#00000','#253494','#2c7fb8','#41b6c4','#a1dab4']
},
"LI_Score": {
"breaks": [4,3,2,1,0],
"colors": ['#00000','#253494','#2c7fb8','#41b6c4','#a1dab4']
}
}
for (var i=0; i < series[layer]["breaks"].length; i++){
if (value > series[layer]["breaks"][i]){
return series[layer]["colors"][i];
}
}
return "#ffffcc";
}
var getIMDStyle = function(feature) {
return {
weight: 1,
opacity: .5,
fillOpacity: fillOpacityValue,
color: (feature.properties) ?getIMDColor(feature.properties[currentLayer]) :null,
fillColor: (feature.properties) ?getIMDColor(feature.properties[currentLayer]) :null}
};
var IPD = L.geoJson(null, {
style: getIMDStyle,
onEachFeature: function (feature, layer) {
feature.id = L.stamp(layer);
if (feature.properties) {
// layer.bindLabel('IPD Score: '+ feature.properties.IPD_Score , {
// className: 'leaflet-label'
// });
layer.on({click: identify});
layer.on({click: populatebarchart});
layer.on({
'click': function (e) {
selectHighlight(e.target);
},
'mouseover': function(e){
hover(e.target);
},
'mouseout': function(e){
mouseOut(e.target);
}
});
}
}
});
$.getJSON("data/IPD16.js", function(data) {
IPD.addData(data);
});
function selectHighlight(target){
if (selected == target._leaflet_id){
IPD.resetStyle(target);
target.bringToBack();
selected = 0;
}
else{
selected = target._leaflet_id;
for (lyr in IPD._layers){
if (IPD._layers[lyr]._leaflet_id !== selected){
IPD.resetStyle(IPD._layers[lyr]);
}
else{
target.setStyle({
weight: 2.5,
color: 'red',
fillOpacity: fillOpacityValue
})
}
}
MCD.bringToFront();
target.bringToFront();
}
};
function hover(target){
if (selected !== target._leaflet_id){
target.setStyle({
weight: 2.5,
color: 'blue',
fillOpacity: fillOpacityValue
})
target.bringToFront();
}
}
function mouseOut(target){
if (selected !== target._leaflet_id){
IPD.resetStyle(target);
target.bringToBack();
}
}
//Basemap Layers
// var mapbox = L.tileLayer.provider('MapBox.crvanpollard.hghkafl4');
// var mapbox = L.tileLayer(
// 'https://api.mapbox.com/styles/v1/mapbox/dark-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoiY3J2YW5wb2xsYXJkIiwiYSI6Ii00ZklVS28ifQ.Ht4KwAM3ZUjo1dT2Erskgg', {
// attribution: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
// });
var CartoDB_Positron = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> © <a href="http://cartodb.com/attributions">CartoDB</a>',
subdomains: 'abcd',
maxZoom: 19
});
var Mapbox_Imagery = L.tileLayer(
'https://api.mapbox.com/styles/v1/crvanpollard/cimpi6q3l00geahm71yhzxjek/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoiY3J2YW5wb2xsYXJkIiwiYSI6Ii00ZklVS28ifQ.Ht4KwAM3ZUjo1dT2Erskgg', {
tileSize: 512,
zoomOffset: -1,
attribution: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});
//create map instance
var map = L.map("mapDIV", {
minZoom: zLevel,
zoomControl: false,
layers: [CartoDB_Positron, DVRPC,MCD, IPD]
}).setView([oLat, oLng],zLevel);
//add Layer Control to map
var baseLayers = {
"Satellite": Mapbox_Imagery,
"Street Map": CartoDB_Positron
// "Street Map (Dark)": mapbox
};
L.control.layers(baseLayers).addTo(map);
function identify(e) {
// alert(fillOpacityValue);
var layer = e.target;
var props = layer.feature.properties;
var locationinfo = "<div class='location-list'>"+(props.MUN1)+", "+(props.CNTY_NAME)+" County <br><p style='font-size:16px'>Census Tract :<a href='https://factfinder.census.gov/bkmk/table/1.0/en/ACS/16_5YR/DP05/1400000US" + (props.GEOID10) + "' target='_blank' class='location-list-link'> "+(props.NAME10)+"</p></div>"
var score = props.IPD_Score
var tractuniverse ="<div>"+ numeral(props.U_TPopEst).format('0,0') +" estimated total population<span class='ipd-stat-moe'>+/- " + numeral(props.U_TPopMOE).format('0,0') +"</span><br>"
+ numeral(props.U_Pop6_Est).format('0,0') +" estimated total population over 5 <span class='ipd-stat-moe'>+/- " + numeral(props.U_Pop6_MOE).format('0,0') +"</span><br>"
+ numeral(props.U_PPovEst).format('0,0') +" estimated total populations in poverty <span class='ipd-stat-moe'>+/- " + numeral(props.U_PPovMOE).format('0,0') +"</span><br>"
+ numeral(props.U_PNICEst).format('0,0') +" estimated non-instiutional civilized pop.<span class='ipd-stat-moe'>+/- " + numeral(props.U_PNICMOE).format('0,0') +"</span><br>"
+"</div>"
if (props.Y_Score == 4 ){ var callout_colorY = '<div class="ipd-stat-score" style="background-color:#253494;color:#fff"> well above average</div>';}
else if (props.Y_Score == 3 ){ var callout_colorY = '<div class="ipd-stat-score" style="background-color:#2c7fb8;color:#fff"> above average</div>' ;}
else if (props.Y_Score == 2 ){ var callout_colorY = '<div class="ipd-stat-score" style="background-color:#41b6c4;color:#fff"> average</div>' ;}
else if (props.Y_Score == 1 ){ var callout_colorY = '<div class="ipd-stat-score" style="background-color:#a1dab4;color:#fff"> below average</div>' ;}
else { var callout_colorY = '<div class="ipd-stat-score" style="background-color:#ffffcc;color:#1a2a2a;"> well below average</div>';}
if (props.OA_Score == 4 ){ var callout_colorOA = '<div class="ipd-stat-score" style="background-color:#253494;color:#fff"> well above average</div>' ;}
else if (props.OA_Score == 3 ){ var callout_colorOA = '<div class="ipd-stat-score" style="background-color:#2c7fb8;color:#fff"> above average</div>' ;}
else if (props.OA_Score == 2 ){ var callout_colorOA = '<div class="ipd-stat-score" style="background-color:#41b6c4;color:#fff"> average</div>' ;}
else if (props.OA_Score == 1 ){ var callout_colorOA = '<div class="ipd-stat-score" style="background-color:#a1dab4;color:#fff"> below average</div>' ;}
else { var callout_colorOA = '<div class="ipd-stat-score" style="background-color:#ffffcc;color:#1a2a2a;"> well below average</div>';}
if (props.F_Score == 4 ){ var callout_colorF = '<div class="ipd-stat-score" style="background-color:#253494;color:#fff"> well above average</div>' ;}
else if (props.F_Score == 3 ){ var callout_colorF = '<div class="ipd-stat-score" style="background-color:#2c7fb8;color:#fff"> above average</div>' ;}
else if (props.F_Score == 2 ){ var callout_colorF = '<div class="ipd-stat-score" style="background-color:#41b6c4;color:#fff"> average</div>' ;}
else if (props.F_Score == 1 ){ var callout_colorF = '<div class="ipd-stat-score" style="background-color:#a1dab4;color:#fff"> below average</div>' ;}
else { var callout_colorF = '<div class="ipd-stat-score" style="background-color:#ffffcc;color:#1a2a2a;"> well below average</div>';}
if (props.RM_Score == 4 ){ var callout_colorRM = '<div class="ipd-stat-score" style="background-color:#253494;color:#fff"> well above average</div>' ;}
else if (props.RM_Score == 3 ){ var callout_colorRM = '<div class="ipd-stat-score" style="background-color:#2c7fb8;color:#fff"> above average</div>' ;}
else if (props.RM_Score == 2 ){ var callout_colorRM = '<div class="ipd-stat-score" style="background-color:#41b6c4;color:#fff"> average</div>' ;}
else if (props.RM_Score == 1 ){ var callout_colorRM = '<div class="ipd-stat-score" style="background-color:#a1dab4;color:#fff"> below average</div>' ;}
else { var callout_colorRM = '<div class="ipd-stat-score" style="background-color:#ffffcc;color:#1a2a2a;"> well below average</div>';}
if (props.EM_Score == 4 ){ var callout_colorEM = '<div class="ipd-stat-score" style="background-color:#253494;color:#fff"> well above average</div>' ;}
else if (props.EM_Score == 3 ){ var callout_colorEM = '<div class="ipd-stat-score" style="background-color:#2c7fb8;color:#fff"> above average</div>' ;}
else if (props.EM_Score == 2 ){ var callout_colorEM = '<div class="ipd-stat-score" style="background-color:#41b6c4;color:#fff"> average</div>' ;}
else if (props.EM_Score == 1 ){ var callout_colorEM = '<div class="ipd-stat-score" style="background-color:#a1dab4;color:#fff"> below average</div>' ;}
else { var callout_colorEM = '<div class="ipd-stat-score" style="background-color:#ffffcc;color:#1a2a2a;"> well below average</div>';}
if (props.FB_Score == 4 ){ var callout_colorFB = '<div class="ipd-stat-score" style="background-color:#253494;color:#fff"> well above average</div>' ;}
else if (props.FB_Score == 3 ){ var callout_colorFB = '<div class="ipd-stat-score" style="background-color:#2c7fb8;color:#fff"> above average</div>' ;}
else if (props.FB_Score == 2 ){ var callout_colorFB = '<div class="ipd-stat-score" style="background-color:#41b6c4;color:#fff"> average</div>' ;}
else if (props.FB_Score == 1 ){ var callout_colorFB = '<div class="ipd-stat-score" style="background-color:#a1dab4;color:#fff"> below average</div>' ;}
else { var callout_colorFB = '<div class="ipd-stat-score" style="background-color:#ffffcc;color:#1a2a2a;"> well below average</div>';}
if (props.LEP_Score == 4 ){ var callout_colorLEP = '<div class="ipd-stat-score" style="background-color:#253494;color:#fff"> well above average</div>' ;}
else if (props.LEP_Score == 3 ){ var callout_colorLEP = '<div class="ipd-stat-score" style="background-color:#2c7fb8;color:#fff"> above average</div>' ;}
else if (props.LEP_Score == 2 ){ var callout_colorLEP = '<div class="ipd-stat-score" style="background-color:#41b6c4;color:#fff"> average</div>' ;}
else if (props.LEP_Score == 1 ){ var callout_colorLEP = '<div class="ipd-stat-score" style="background-color:#a1dab4;color:#fff"> below average</div>' ;}
else { var callout_colorLEP = '<div class="ipd-stat-score" style="background-color:#ffffcc;color:#1a2a2a;"> well below average</div>';}
if (props.D_Score == 4 ){ var callout_colorD = '<div class="ipd-stat-score" style="background-color:#253494;color:#fff"> well above average</div>' ;}
else if (props.D_Score == 3 ){ var callout_colorD = '<div class="ipd-stat-score" style="background-color:#2c7fb8;color:#fff"> above average</div>' ;}
else if (props.D_Score == 2 ){ var callout_colorD = '<div class="ipd-stat-score" style="background-color:#41b6c4;color:#fff"> average</div>' ;}
else if (props.D_Score == 1 ){ var callout_colorD = '<div class="ipd-stat-score" style="background-color:#a1dab4;color:#fff"> below average</div>' ;}
else { var callout_colorD = '<div class="ipd-stat-score" style="background-color:#ffffcc;color:#1a2a2a;"> well below average</div>';}
if (props.LI_Score == 4 ){ var callout_colorLI = '<div class="ipd-stat-score" style="background-color:#253494;color:#fff"> well above average</div>' ;}
else if (props.LI_Score == 3 ){ var callout_colorLI = '<div class="ipd-stat-score" style="background-color:#2c7fb8;color:#fff"> above average</div>' ;}
else if (props.LI_Score == 2 ){ var callout_colorLI = '<div class="ipd-stat-score" style="background-color:#41b6c4;color:#fff"> average</div>' ;}
else if (props.LI_Score == 1 ){ var callout_colorLI = '<div class="ipd-stat-score" style="background-color:#a1dab4;color:#fff"> below average</div>' ;}
else { var callout_colorLI = '<div class="ipd-stat-score" style="background-color:#ffffcc;color:#1a2a2a;"> well below average</div>';}
var tractdata = "<div><h3><i aria-hidden='true' class='far fa-address-card fa-2x'></i> IPD Indicators <sup><i class='glyphicon glyphicon-info-sign' id='info-icon' onclick='legendraw()'></i></sup></h3></div>"
+"<div class='ipd-chart-info'>The information below provides tract-level estimated percentages, Margin of Error (MOE), and IPD Score Classification for our nine indicators. The entire set of indicators data and scores may be downloaded from our Open Data Portal for further analysis.</div>"
+"<div class='row'>"
+"<div class='col-md-6'>"
+"<div class='tooltip-IPD-info' id='Youth1' onClick=myHandler() >Youth <sup><i class='glyphicon glyphicon-info-sign' id='Youth1'></i></sup><span class='tooltip-IPD-info-text'>Learn more about this indicator</span></div>"
+"<div id='indicator-callout'><span class='ipd-stat'>" + numeral(props.Y_PctEst).format('0.0%') +"</span><span class='ipd-stat-moe'>+/- " + numeral(props.Y_PctMOE).format('0.0%') +"</span><br><span class='ipd-stat-footer'> of residents are 18 years or younger</span>"+ callout_colorY +"</div></div>"
+"<div class='col-md-6'>"
+"<div class='tooltip-IPD-info-top' id='Older1' onClick=myHandler()>Older Adults <sup><i class='glyphicon glyphicon-info-sign' id='Older1'></i></sup><span class='tooltip-IPD-info-top-text'>Learn more about this indicator</span></div>"
+"<div id='indicator-callout'><span class='ipd-stat'>"+numeral(props.OA_PctEst).format('0.0%') +"</span><span class='ipd-stat-moe'>+/- " + numeral(props.OA_PctMOE).format('0.0%') +"</span><br><span class='ipd-stat-footer'> of residents are 65 years or older </span>"+ callout_colorOA +"</div></div>"
+"</div>"
+"<div class='row'>"
+"<div class='col-md-6'>"
+"<div class='tooltip-IPD-info' id='Female1' onClick=myHandler()>Female <sup><i class='glyphicon glyphicon-info-sign' id='Female1'></i></sup><span class='tooltip-IPD-info-text'>Learn more about this indicator</span></div>"
+"<div id='indicator-callout'><span class='ipd-stat'>"+numeral(props.F_PctEst).format('0.0%') +"</span><span class='ipd-stat-moe'>+/- " + numeral(props.F_PctMOE).format('0.0%') +"</span><br><span class='ipd-stat-footer'> residents are female</span>"+ callout_colorF +"</div></div>"
+"<div class='col-md-6'>"
+"<div class='tooltip-IPD-info-top' id='Racial1' onClick=myHandler()>Racial Minority <sup><i class='glyphicon glyphicon-info-sign' id='Racial1'></i></sup> <span class='tooltip-IPD-info-top-text'>Learn more about this indicator</span></div>"
+"<div id='indicator-callout'><span class='ipd-stat'>" + numeral(props.RM_PctEst).format('0.0%') +"</span><span class='ipd-stat-moe'>+/- " + numeral(props.RM_PctMOE).format('0.0%') +"</span><br><span class='ipd-stat-footer'> of residents identify as one or more races considered under Title VI and EJ</span>"+ callout_colorRM +" </div></div>"
+"</div>"
+"<div class='row'>"
+"<div class='col-md-6'>"
+"<div class='tooltip-IPD-info' id='Ethnic1' onClick=myHandler()>Ethnic Minority <sup><i class='glyphicon glyphicon-info-sign' id='Ethnic1'></i></sup><span class='tooltip-IPD-info-text'>Learn more about this indicator </span></div>"
+"<div id='indicator-callout'><span class='ipd-stat'>"+numeral(props.EM_PctEst).format('0.0%') +"</span><span class='ipd-stat-moe'>+/- " + numeral(props.EM_PctMOE).format('0.0%') +"</span><br><span class='ipd-stat-footer'> of residents identified themselves as being of Hispanic, Latino, Spanish, Mexican, Chicano, Cuban, Puerto Rican, or Other Hispanic origin. </span>"+ callout_colorEM +"</div></div>"
+"<div class='col-md-6'>"
+"<div class='tooltip-IPD-info-top' id='Foreign1' onClick=myHandler()>Foreign Born <sup><i class='glyphicon glyphicon-info-sign' id='Foreign1'></i></sup><span class='tooltip-IPD-info-top-text'>Learn more about this indicator</span></div>"
+"<div id='indicator-callout' ><span class='ipd-stat'>"+numeral(props.FB_PctEst).format('0.0%') +"</span><span class='ipd-stat-moe'>+/- " + numeral(props.FB_PctMOE).format('0.0%') +"</span><br><span class='ipd-stat-footer'> of residents were born outside of the United States</span>"+ callout_colorFB +"</div></div>"
+"</div>"
+"<div class='row'>"
+"<div class='col-md-6'>"
+"<div class='tooltip-IPD-info' id='LEP1' onClick=myHandler()> Limited English Proficiency <sup><i class='glyphicon glyphicon-info-sign' id='LEP1'></i></sup> <span class='tooltip-IPD-info-text'>Learn more about this indicator </span></div>"
+"<div id='indicator-callout'><span class='ipd-stat'>" + numeral(props.LEP_PctEst).format('0.0%') +"</span><span class='ipd-stat-moe'>+/- " + numeral(props.LEP_PctMOE).format('0.0%') +"</span><br><span class='ipd-stat-footer'> of residents report having English proficiency below “very well”</span>"+ callout_colorLEP +" </div></div>"
+"<div class='col-md-6'>"
+"<div class='tooltip-IPD-info-top' id='Disabled1' onClick=myHandler()> Disabled <sup><i class='glyphicon glyphicon-info-sign' id='Disabled1'></i></sup> <span class='tooltip-IPD-info-top-text'>Learn more about this indicator </span></div>"
+"<div id='indicator-callout'><span class='ipd-stat'>"+numeral(props.D_PctEst).format('0.0%') +"</span><span class='ipd-stat-moe'>+/- " + numeral(props.D_PctMOE).format('0.0%') +"</span><br><span class='ipd-stat-footer'> of residents with one or more physical and/or mental disabilities</span>"+ callout_colorD +"</div></div>"
+"</div>"
+"<div class='row'>"
+"<div class='col-md-6'>"
+"<div class='tooltip-IPD-info' id='Low-Income1' onClick=myHandler()>Low-Income <sup><i class='glyphicon glyphicon-info-sign' id='Low-Income1'></i></sup><span class='tooltip-IPD-info-text'>Learn more about this indicator </span></div>"
+"<div id='indicator-callout'><span class='ipd-stat'>"+numeral(props.LI_PctEst).format('0.0 %') +"</span><span class='ipd-stat-moe'>+/- " + numeral(props.LI_PctMOE).format('0.0%') +"</span><br><span class='ipd-stat-footer'> of residents live in households with an income at or below 200% of the national poverty level</span>"+ callout_colorLI +"</div></div>"
+"</div>"
document.getElementById('location_info').innerHTML = locationinfo;
document.getElementById('odometer').innerHTML = score;
document.getElementById('tractuniverse-data').innerHTML = tractuniverse;
document.getElementById('tract-data').innerHTML = tractdata;
$('#location_info').show();
$('#odometer').show();
$('#tractuniverse-data').show();
$('#tractinfo_panel').show();
$('#Map-layers').show();
$('#MapButtons').show();
$('#MapButtons-title').show();
$('#cardclick').hide();
};
$('#layer-change a').on('click', function (e) {
currentLayer = $(this).data("value");
if (currentLayer == 'none') {
map.removeLayer(IPD);
} else {
if (!map.hasLayer(IPD)) {
map.addLayer(IPD);
} else {
IPD.setStyle(getIMDStyle);
L.DomEvent.preventDefault(e);
}
}
});
$('#layer-change a').on('click', function (e) {
currentLayer = $(this).data("value");
if (currentLayer == 'IPD_Score') {
$("#container_ipd").show('slow');
$("#container_ipdg").hide('slow');
} else {
$("#container_ipd").hide('slow');
$("#container_ipdg").show('slow');
}
});
$('#layer-change a').on('click', function (e) {
var selText = $(this).text();
$(this).parents('.btn-group').find('.dropdown-toggle').html(selText +'<span class="caret"></span>');
});
// IPD Group Histogram Chart
$(function () {
var xAxisLabels = {categories: ['0.0% to 12.4%','12.5% to 18.6%', '18.7% to 24.8%', '24.9% to 31.0%', '31.1% to 100.0%']};
var xAxisLabels2 = {categories: ['0.0% to 4.7%','4.8% to 11.5%', '11.6% to 18.2%', '18.3% to 24.9%', '25.0% to 100.0%']};
var xAxisLabels3 = {categories: ['0.0% to 44.6%','44.7% to 49.3%', '49.4% to 53.9%', '54.0% to 58.6%', '58.7% to 100.0%']};
var xAxisLabels4 = {categories: ['0.0% to 0.0%','0.1% to 18.5%', '18.6% to 48.3%', '48.4% to 78.0%', '78.1% to 100.0%']};
var xAxisLabels5 = {categories: ['0.0% to 0.0%','0.1% to 2.4%', '2.5% to 15.4%', '15.5% to 28.3%', '28.4% to 100.0%']};
var xAxisLabels6 = {categories: ['0.0% to 0.0%','0.1% to 6.2%', '6.3% to 14.9%', '15.0% to 23.6%', '23.7% to 100.0%']};
var xAxisLabels7 = {categories: ['0.0% to 0.0%','0.1% to 2.4%', '2.5% to 10.1%', '10.2% to 17.8%', '17.9% to 100.0%']};
var xAxisLabels8 = {categories: ['0.0% to 4.0%','4.1% to 9.7%', '9.8% to 15.4%', '15.5% to 21.1%', '21.2% to 100.0%']};
var xAxisLabels9 = {categories: ['0.0% to 0.0%','0.1% to 18.3%', '18.4% to 38.8%', '38.9% to 59.2%', '59.3% to 100.0%']};
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container_ipdg',
backgroundColor: null,
type: 'column'
},
title:{
text:''
},
yAxis: {
allowDecimals: false,
title: {
text: 'Regional Distribution<br> of Census Tracts'
},
tickInterval: 100,
labels: {
step: 2
},
min: 0,
max: 900
},
colors: ["#ffffcc", "#a1dab4", "#41b6c4", "#2c7fb8", "#253494"],
plotOptions: {
bar: {
colorByPoint: true
}
},
tooltip: { enabled: false },
legend: {
enabled: false
},
credits: {
enabled: false
},
series: [{
data: [{y:84,color:'#ffffcc'}, {y:272,color:'#a1dab4'}, {y:648,color:'#41b6c4'}, {y:277,color:'#2c7fb8'}, {y:88,color:'#253494'}]
}]
});
$('#layer-change li:eq(1)').click(function(){
chart.series[0].setData([{y:84,color:'#ffffcc'}, {y:272,color:'#a1dab4'}, {y:648,color:'#41b6c4'}, {y:277,color:'#2c7fb8'}, {y:88,color:'#253494'}] );
chart.yAxis[0].setExtremes(0,900);
chart.update({
tooltip: {
enabled: true,
formatter: function () {
return 'There are <b>' + this.y +
'</b> census tracts with this score</b>';
}
},
title: {
text: 'Youth',
align: 'center',
verticalAlign: 'bottom',
floating: true
},
tickInterval: 100,
xAxis: xAxisLabels
});
});
$('#layer-change li:eq(2)').click(function() {
chart.series[0].setData([{y:33,color:'#ffffcc'}, {y:390,color:'#a1dab4'}, {y:643,color:'#41b6c4'}, {y:219,color:'#2c7fb8'}, {y:84,color:'#253494'}] );
chart.yAxis[0].setExtremes(0,900);
chart.update({
yAxis: {
tickInterval: 100
},
xAxis: xAxisLabels2,
title: {
text: 'Older Adults',
align: 'center',
verticalAlign: 'bottom',
floating: true
}
});
});
$('#layer-change li:eq(3)').click(function() {
chart.series[0].setData([{y:37,color:'#ffffcc'}, {y:292,color:'#a1dab4'}, {y:704,color:'#41b6c4'}, {y:280,color:'#2c7fb8'}, {y:56,color:'#253494'}] );
chart.yAxis[0].setExtremes(0,900);
chart.update({
yAxis: {
tickInterval: 100
},
xAxis: xAxisLabels3,
title: {
text: 'Female',
align: 'center',
verticalAlign: 'bottom',
floating: true
}
});
});
$('#layer-change li:eq(4)').click(function() {
chart.series[0].setData([{y:2,color:'#ffffcc'}, {y:602,color:'#a1dab4'}, {y:414,color:'#41b6c4'}, {y:148,color:'#2c7fb8'}, {y:203,color:'#253494'}] );
chart.yAxis[0].setExtremes(0,900);
chart.update({
yAxis: {
tickInterval: 100
},
xAxis: xAxisLabels4,
title: {
text: 'Racial Minority',
align: 'center',
verticalAlign: 'bottom',
floating: true
}
});
});
$('#layer-change li:eq(5)').click(function() {
chart.series[0].setData([{y:25,color:'#ffffcc'}, {y:343,color:'#a1dab4'}, {y:810,color:'#41b6c4'}, {y:97,color:'#2c7fb8'}, {y:94,color:'#253494'}] );
chart.yAxis[0].setExtremes(0,900);
chart.update({
yAxis: {
tickInterval: 100
},
xAxis: xAxisLabels5,
title: {
text: 'Ethnic Minority',
align: 'center',
verticalAlign: 'bottom',
floating: true
}
});
});
$('#layer-change li:eq(6)').click(function() {
chart.series[0].setData([{y:1,color:'#ffffcc'}, {y:509,color:'#a1dab4'}, {y:566,color:'#41b6c4'}, {y:177,color:'#2c7fb8'}, {y:116,color:'#253494'}] );
chart.yAxis[0].setExtremes(0,900);
chart.update({
yAxis: {
tickInterval: 100
},
xAxis: xAxisLabels6,
title: {
text: 'Foreign Born',
align: 'center',
verticalAlign: 'bottom',
floating: true
}
});
});
$('#layer-change li:eq(7)').click(function() {
chart.series[0].setData([{y:19,color:'#ffffcc'}, {y:480,color:'#a1dab4'}, {y:636,color:'#41b6c4'}, {y:114,color:'#2c7fb8'}, {y:120,color:'#253594'}] );
chart.yAxis[0].setExtremes(0,900);
chart.update({
yAxis: {
tickInterval: 100
},
xAxis: xAxisLabels7,
title: {
text: 'Limited English Proficiency',
align: 'center',
verticalAlign: 'bottom',
floating: true
}
});
});
$('#layer-change li:eq(8)').click(function() {
chart.series[0].setData([{y:21,color:'#ffffcc'}, {y:434,color:'#a1dab4'}, {y:555,color:'#41b6c4'}, {y:270,color:'#2c7fb8'}, {y:88,color:'#253594'}] );
chart.yAxis[0].setExtremes(0,900);
chart.update({
yAxis: {
tickInterval: 100
},
xAxis: xAxisLabels8,
title: {
text: 'Disabled',
align: 'center',
verticalAlign: 'bottom',
floating: true
},
});
});
$('#layer-change li:eq(9)').click(function() {
chart.series[0].setData([{y:2,color:'#ffffcc'},{y:569,color:'#a1dab4'}, {y:434,color:'#41b6c4'}, {y:203,color:'#2c7fb8'}, {y:160,color:'#253594'}] );
chart.yAxis[0].setExtremes(0,900);
chart.update({
yAxis: {
tickInterval: 100
},
xAxis: xAxisLabels9,
title: {
text: 'Low-Income',
align: 'center',
verticalAlign: 'bottom',
floating: true
}
});
});
});
// Main IPD Chart
$(function () {
var yAxisLabels = [9,35];
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container_ipd',
backgroundColor: null,
type: 'bar'
},
title:{
text:''
},
xAxis: {
title: {
text: null
},
labels: {
enabled:false //default is true
},
lineWidth: 0,
minorGridLineWidth: 0,
lineColor: 'transparent',
minorTickLength: 0,
tickLength: 0
},
yAxis: {
allowDecimals: false,
startOnTick: false,
title: {
text: 'Composite Value by Census Tract'
},
labels: {
enabled: true,
distance: 25,
formatter: function() {
var value = this.value, string;
if (value < 10) {
string = 'Lower (9)'
} else if (value < 34) {
string = 'heavy'
} else if (value < 100) {
string = 'Higher (35)'
} else string = 'critical';
return string;
}
},
tickPosition: 'outside',
tickPositions: [9, 35],
min: 9,
max: 34
},
colors: [{
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1},
stops: [
[0, '#253494'],
[.25,'#2c7fb8'],
[.5,'#41b6c4'],
[.75,'#a1dab4'],
[1, '#ffffcc']
]
},
],
// colors: ["#ffffcc", "#a1dab4", "#41b6c4", "#2c7fb8", "#253494"],
plotOptions: {
bar: {
colorByPoint: true
}
},
tooltip: { enabled: false },
legend: {
enabled: false
},
credits: {
enabled: false
},
series: [{
data: [35]
}]
});
});
function populatebarchart(e) {
var layer = e.target;
var props = layer.feature.properties,
ExistingTOD = [props.Y_Score,props.OA_Score,props.F_Score,props.RM_Score,props.FB_Score,props.EM_Score,props.LEP_Score,props.D_Score,props.LI_Score];
updatebarchart(ExistingTOD);
}
function updatebarchart(Values) {
var options = {
chart: {
renderTo: 'ipd-barchart',
type:'bar',
plotBackgroundColor: null,
plotBorderWidth: 0,//null,
plotShadow: false,
//height:280;
height:220,
spacingLeft: 10,
// spacingRight: 60,
backgroundColor: '#EFEFEF'
},
// colors: ['#bca6c2']
// ,
credits: {
enabled: false
},
title: {
// text: 'Bicycle Volume by Month',
text: null,
x: -20 //center
},
xAxis: {
categories: [ 'Youth','Older Adults','Female','Racial Minority','Ethnic Minority','Foreign Born','LEP','Disabled','Low-Income'],
tickColor: 'transparent',
lineColor: 'transparent',
labels: {useHTML: true}
},
yAxis: {
min: 0,
max: 4,
// height: 230,
height:170,
allowDecimals: false,
// categories: ['A', 'B', 'C','D','E'],
labels: {useHTML: true},
// gridLineColor: "red",
tickmarkPlacement: 'on',
title: {
text: ''
}
},
legend: {
enabled: false
},
/* credits: {
position: {
align: 'left',
x: 5,
y: -5 // position of credits
},
text: 'click category name for description',
href: null
},
*/ tooltip: {
enabled: false
},
series: [{
name:'Total',
id: 'Values',
color: '#582267',
data: []
}]
};
var Labels = [],
counData = [];
for (var i = 0; i < Values.length; i++){
counData.push({
name: Labels[i],
y: Values[i]})
}
options.series[0].data = counData;
chart = new Highcharts.Chart(options)
$('.highcharts-xaxis-labels text, .highcharts-xaxis-labels span').click(function () {
// console.log(this.textContent.split(' ')[0]);
EXTODdraw(this.textContent.split(' ')[0]);
});
// console.log(bikeindata);
}
// Legend
L.Control.MapLegend = L.Control.extend({
options: {
position: 'bottomright',
},
onAdd: function (map) {
//TODO: Probably should throw all this data in a class and just loop through it all
var legendDiv = L.DomUtil.create('div', 'map-legend legend-control leaflet-bar');
legendDiv.innerHTML += '<div id="legend-icon" title="Toggle Legend"><i class="glyphicon glyphicon-minus"></i><span class="legend-label" style="display:none;"> Legend</span></div>';
var legend_top = L.DomUtil.create('div', 'map-legend-items legend-top', legendDiv),
legend_body = L.DomUtil.create('div', 'map-legend-items legend-body', legendDiv),
legend_bottom = L.DomUtil.create('div', 'map-legend-items legend-bottom', legendDiv);
legend_body.innerHTML += '<div id="legend-content" class="row">'+
'<div class="col-xs-2 col-sm-2">'+
'<div class="row" id="legend-row"><i class="fa fa-square ipd-e"></i></div>'+
'<div class="row" id="legend-row"><i class="fa fa-square ipd-d"></i></div>'+
'<div class="row" id="legend-row"><i class="fa fa-square ipd-c"></i></div>'+
'<div class="row"id="legend-row"><i class="fa fa-square ipd-b"></i></div>'+
'<div class="row"id="legend-row"><i class="fa fa-square ipd-a"></i></div>'+
'</div>'+
'<div class="col-xs-8 col-sm-8">'+
'<div class="row" id="legend-row"><span class="nav-text">well above average</span></div>'+
'<div class="row" id="legend-row"><span class="nav-text">above average</span></div>'+
'<div class="row" id="legend-row"><span class="nav-text">average</span></div>'+
'<div class="row" id="legend-row"><span class="nav-text">below average</span></div>'+
'<div class="row" id="legend-row"><span class="nav-text">well below average</span></div></div>';
legend_top.innerHTML += '<p id="legend-title-content"><b>IPD Score Analysis</b></p>'
legendDiv.setAttribute('data-status', 'open');
return legendDiv;
}
});
var mapLegend = new L.Control.MapLegend();
map.addControl(mapLegend);
// after interacting with the layer list dropdown...
$("#layer-change").children().on('click', function(){
// get the new text
var newLayer = $(this).text();
// change the legend to reflect the new text!
$("#legend-title-content").text(newLayer+" Classification");
});
/*
Leaflet.OpacityControls, a plugin for adjusting the opacity of a Leaflet map.
(c) 2013, Jared Dominguez
(c) 2013, LizardTech
https://github.com/lizardtechblog/Leaflet.OpacityControls
*/
//Create a control to increase the opacity value. This makes the image more opaque.
L.Control.higherOpacity = L.Control.extend({
options: {
position: 'topright'
},
setOpacityLayer: function (layer) {
opacity_layer = layer;
},
onAdd: function () {
var higher_opacity_div = L.DomUtil.create('div', 'higher_opacity_control');
L.DomEvent.addListener(higher_opacity_div, 'click', L.DomEvent.stopPropagation)
.addListener(higher_opacity_div, 'click', L.DomEvent.preventDefault)
.addListener(higher_opacity_div, 'click', function () { onClickHigherOpacity() });
return higher_opacity_div;
}
});
//Create a control to decrease the opacity value. This makes the image more transparent.
L.Control.lowerOpacity = L.Control.extend({
options: {
position: 'topright'
},
setOpacityLayer: function (layer) {
opacity_layer = layer;
},
onAdd: function (map) {
var lower_opacity_div = L.DomUtil.create('div', 'lower_opacity_control');
L.DomEvent.addListener(lower_opacity_div, 'click', L.DomEvent.stopPropagation)
.addListener(lower_opacity_div, 'click', L.DomEvent.preventDefault)
.addListener(lower_opacity_div, 'click', function () { onClickLowerOpacity() });
return lower_opacity_div;
}
});
//Create a jquery-ui slider with values from 0 to 100. Match the opacity value to the slider value divided by 100.
L.Control.opacitySlider = L.Control.extend({
options: {
position: 'bottomleft'
},
setOpacityLayer: function (layer) {
opacity_layer = layer;
},
onAdd: function (map) {
var opacity_slider_div = L.DomUtil.create('div', 'opacity-slider-control');
$(opacity_slider_div).slider({
orientation: "vertical",
range: "min",
min: 0,
max: 100,
value: 70,
step: 10,
start: function ( event, ui) {
//When moving the slider, disable panning.
map.dragging.disable();
map.once('mousedown', function (e) {
map.dragging.enable();
});
},
slide: function (event, ui) {
fillOpacityValue = ui.value / 100;
var slider_value = ui.value / 100;
opacity_layer.setStyle({
fillOpacity: slider_value
})
// alert(slider_value);
}
});
$('.opacity-slider-control').css("margin-left", "18px");
return opacity_slider_div;
}
});
function onClickHigherOpacity() {
var opacity_value = opacity_layer.options.opacity;
if (opacity_value > 1) {
return;
} else {
opacity_layer.setOpacity(opacity_value + 0.2);
//When you double-click on the control, do not zoom.
map.doubleClickZoom.disable();
map.once('click', function (e) {
map.doubleClickZoom.enable();
});
}
}
function onClickLowerOpacity() {
var opacity_value = opacity_layer.options.opacity;
if (opacity_value < 0) {
return;
} else {
opacity_layer.setOpacity(opacity_value - 0.2);
//When you double-click on the control, do not zoom.
map.doubleClickZoom.disable();
map.once('click', function (e) {
map.doubleClickZoom.enable();
});
}
}
//------------------------------------------- //
// ------ Opacity Slider Functionality ------ //
//------------------------------------------- //
// Opacity Slider sourced from lizardtechblog | github.com/lizardtechblog
var opacitySlider = new L.Control.opacitySlider();
map.addControl(opacitySlider);
opacitySlider.setOpacityLayer(IPD);
IPD.setStyle({
fillOpacity: fillOpacityValue
});
// Prevent map dragging when slider is active //
$('#slide').on('mouseover', function(e) {
e.preventDefault();
e.stopPropagation();
map.dragging.disable();
});