-
Notifications
You must be signed in to change notification settings - Fork 42
/
canada.html
98 lines (93 loc) · 3.12 KB
/
canada.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
<!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="canada" style="height: 600px; width: 900px;"></div>
<script>
var bubble_map = new Datamap({
element: document.getElementById('canada'),
scope: 'canada',
geographyConfig: {
popupOnHover: true,
highlightOnHover: true,
borderColor: '#444',
borderWidth: 0.5,
dataUrl: 'https://rawgit.com/Anujarya300/bubble_maps/master/data/geography-data/canada.topo.json'
//dataJson: topoJsonData
},
fills: {
'MAJOR': '#306596',
'MEDIUM': '#0fa0fa',
'MINOR': '#bada55',
defaultFill: '#dddddd'
},
data: {
'JH': { fillKey: 'MINOR' },
'MH': { fillKey: 'MINOR' }
},
setProjection: function (element) {
var projection = d3.geo.mercator()
.center([-106.3468, 68.1304]) // always in [East Latitude, North Longitude]
.scale(250)
.translate([element.offsetWidth / 2, element.offsetHeight / 2]);
var path = d3.geo.path().projection(projection);
return { path: path, projection: projection };
}
});
let bubbles = [
{
centered: "MB",
fillKey: "MAJOR",
radius: 20,
state: "Manitoba"
},
{
centered: "AB",
fillKey: "MAJOR",
radius: 22,
state: "Alberta"
},
{
centered: "NT",
fillKey: "MAJOR",
radius: 40,
state: "Northwest Territories"
},
{
centered: "NU",
fillKey: "MEDIUM",
radius: 60,
state: "Nunavut"
},
{
centered: "BC ",
fillKey: "MEDIUM",
radius: 15,
state: "British Columbia"
},
{
centered: "QC",
fillKey: "MINOR",
radius: 8,
state: "Québec"
},
{
centered: "NB",
fillKey: "MINOR",
radius: 50,
state: "New Brunswick"
}
]
// // 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.state}, Slums: ${data.radius}%</div>`;
}
});
}, 1000);
</script>
</body>
</html>