-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
119 lines (95 loc) · 3.55 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
<link rel="stylesheet" type="text/css" href="jquery.qtip.css">
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="raphael-2.1.0.min.js"></script>
<script type="text/javascript" src="jquery.qtip.min.js"></script>
<script type="text/javascript" src="kartograph.js"></script>
<script type="text/javascript">
$(function() {
// initialize tooltips
$.fn.qtip.defaults.style.classes = 'ui-tooltip-bootstrap';
$.fn.qtip.defaults.style.def = false;
$.getJSON('uk-visits.json', function(cities) {
function map(cont, clustering, zm) {
var map = kartograph.map(cont);
map.loadMap('GBR.svg', function() {
map.addLayer('context', {
styles: {
stroke: '#aaa',
fill: '#f6f4f2'
}
});
map.addLayer('regions', {
id: 'bg',
styles: {
stroke: '#d8d6d4',
'stroke-width': 10,
'stroke-linejoin': 'round'
}
});
map.addLayer('regions', {
title: function(d) { return d.name },
styles: {
stroke: '#333',
fill: '#fff'
}
});
var scale = kartograph.scale.sqrt(cities.concat([{ nb_visits: 0 }]), 'nb_visits').range([2, 30]);
map.addSymbols({
type: kartograph.Bubble,
data: cities,
clustering: clustering,
aggregate: function(cities) {
var nc = { nb_visits: 0, city_names: [] };
$.each(cities, function(i, c) {
nc.nb_visits += c.nb_visits;
nc.city_names = nc.city_names.concat(c.city_names ? c.city_names : [c.city_name]);
});
nc.city_name = nc.city_names[0] + ' and ' + (nc.city_names.length-1) + ' others';
return nc;
},
location: function(city) {
return [city.long, city.lat];
},
radius: function(city) {
return scale(city.nb_visits);
},
tooltip: function(city) {
return '<h3>'+city.city_name+'</h3>'+city.nb_visits+' detected violations';
},
sortBy: 'radius desc',
style: 'fill:#800; stroke: #fff; fill-opacity: 0.5;',
});
}, { padding: -75 });
}
map('#map0','',3);
map('#map2', 'noverlap',1);
});
});
</script>
<style type="text/css">
.uk-map {
width: 41%;
display: inline-block;
margin-right: 10px;
vertical-align: top;
}
.uk-map label {
text-align: center;
font-style: italic;
}
.uk-map div {
height: 600px;
border: 1px solid #bbb;
margin-bottom: 1em;
}
</style>
<div class="uk-map">
<div id="map2"></div>
<p><b>High Level View</b> Detections are clustered, and combined when they overlap. This retains information in regions with lower densities.<p>
</div>
<div class="uk-map">
<div id="map0"></div>
<p><b>Detail View</b> Shows possible detections localised by particular suburb without any clustering</p>
</div>
<br>
<b>Mouse over for tooltips showing clustering</b>