-
Notifications
You must be signed in to change notification settings - Fork 42
/
usa.html
137 lines (133 loc) · 3.97 KB
/
usa.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
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script src="https://rawgit.com/Anujarya300/bubble_maps/master/data/geography-data/datamaps.none.js"></script>
<div id="usa" style="height: 600px; width: 900px;"></div>
<script>
var bubble_map = new Datamap({
element: document.getElementById('usa'),
scope: 'usa',
geographyConfig: {
popupOnHover: true,
highlightOnHover: true,
borderColor: '#444',
borderWidth: 0.5,
dataUrl: 'https://rawgit.com/Anujarya300/bubble_maps/master/data/geography-data/usa.topo.json'
//dataJson: topoJsonData
},
fills: {
'MAJOR': '#306596',
'MEDIUM': '#0fa0fa',
'MINOR': '#bada55',
defaultFill: '#dddddd'
},
data: {
'NY': { fillKey: 'MINOR' },
'CA': { fillKey: 'MINOR' }
}
});
let bubbles = [
{
"centered":"NY",
"city": "New York",
"radius": 25,
"fillKey": "MEDIUM"
},
{
"centered":"AL",
"city": "Alabama",
"radius": 12,
"fillKey": "MINOR"
},
{
"centered":"AK",
"city": "Alaska",
"radius": 30,
"fillKey": "MEDIUM"
},
{
"centered":"AZ",
"city": "Arizona",
"radius": 22,
"fillKey": "MINOR"
},
{
"centered":"MD",
"city": "Maryland",
"radius": 39,
"fillKey": "MAJOR"
},
{
"centered":"OK",
"city": "Oklahoma",
"radius": 30,
"fillKey": "MEDIUM"
},
{
"centered":"PA",
"city": "Pennsylvania",
"radius": 15,
"fillKey": "MONOR"
},
{
"centered":"SC",
"city": "South Carolina",
"radius": 16,
"fillKey": "MINOR"
},
{
"centered":"TN",
"city": "Tennessee",
"radius": 44,
"fillKey": "MAJOR"
},
{
"centered":"UT",
"city": "Utah",
"radius": 33,
"fillKey": "MEDIUM"
},
{
"centered":"VT",
"city": "Vermont",
"radius": 32,
"fillKey": "MEDIUM"
},
{
"centered":"TX",
"city": "Texas",
"radius": 35,
"fillKey": "MEDIUM"
},
{
"centered":"WI",
"city": "Wisconsin",
"radius": 40,
"fillKey": "MINOR"
},
{
"centered":"WV",
"city": "West Virginia",
"radius": 45,
"fillKey": "MEDIUM"
},
{
"centered":"WA",
"city": "Washington",
"radius": 56,
"fillKey": "MAJOR"
}
]
// // ISO ID code for city or <state></state>
setTimeout(() => { // only start drawing bubbles on the map when map has rendered completely.
bubble_map.bubbles(bubbles, {
popupTemplate: function (geo, data) {
return `<div class="hoverinfo">city: ${data.city}, Slums: ${data.radius}%</div>`;
}
});
}, 1000);
</script>
</body>
</html>