-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
245 lines (223 loc) · 10.4 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fire Engine Callouts - Amsterdam Amstelland</title>
<meta name="author" content="Edward Mac Gillavry">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
<style>
html {
-webkit-font-smoothing: antialiased;
color: #333;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-size: 14px;
line-height: 20px;
}
#map_canvas, html, body {
width: 100%; height: 100%; padding: 0; margin: 0;
}
#map_canvas {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAMAAABhq6zVAAAACVBMVEUAAADl5eX////EwbxGAAAAAXRSTlMAQObYZgAAABFJREFUeAFjYESCKACdT38ZAAWhAAxcPQc7AAAAAElFTkSuQmCC) repeat scroll 0 0 #f9f9f9;
cursor: move;
-webkit-tap-highlight-color: transparent;
}
header {
position: absolute;
right: 10px;
bottom: 40px;
width: 250px;
z-index: 10;
padding: 10px;
background-color: #fefefe;
border: 1px solid #ccc;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
filter: alpha(opacity=80);
-moz-opacity: 0.8;
-khtml-opacity: 0.8;
opacity: 0.8;
}
header img {
margin: 30px auto 0;
display: block;
}
h1 {
font-size: 20px;
color: #980000;
}
h2 {
font-size: 18px;
}
a {
color: #980000;
}
#torque_time {
color: #fff;
display: block;
position: absolute;
left: 50%;
top: 20px;
width: 189px;
text-align: center;
font-weight: bold;
padding: 3px;
vertical-align: middle;
background-color: #980000;
border: 1px white dashed;
}
#toggle-button {
background: url("http://www.webmapper.net/img/toggle-button.png") no-repeat scroll 0 0 rgba(0,0,0,0);
position: absolute;
bottom: 50px;
right: 20px;
z-index: 1000;
width: 25px;
height: 25px;
}
#toggle-button.closed {
background-position: 0 -25px;
}
#twitter-button {
width: 85px;
height: 22px;
background-color: rgba(30,30,30,0.9);
border: solid #333;
border-width: 1px;
padding: 5px;
position: fixed;
bottom: 5px;
left: 90px;
z-index: 999;
}
#twitter-button .twitter-share-button {
margin: 0;
padding: 0;
}
a.cartodb_logo {
background: url("http://cartodb.s3.amazonaws.com/embed/embed_sprite.png") no-repeat scroll -61px 0 rgba(0, 0, 0, 0);
bottom: 10px;
display: block;
font-size: 0;
height: 27px;
left: 10px;
line-height: 0;
position: absolute;
text-indent: -9999px;
width: 69px;
}
img.leaflet-tile {
position: absolute;
left: 0;
top: 0;
-webkit-filter: hue-rotate(180deg) invert(100%) saturate(30%);
filter: url(filter.svg#darken);
}
</style>
<body>
<div id="map_canvas"></div>
<div id="torque_time"></div>
<header>
<h1>Fire engine callouts</h1>
<p>The fire brigade in the <a href="http://www.brandweer.nl/amsterdam-amstelland/">Amsterdam-Amstelland</a> area responded to over <strong>62,415</strong> incidents between January 2006 and September 2010. The <a href="http://www.hackdeoverheid.nl/wp-content/uploads/2011/03/BrwAAincidenten_reshaped.zip">data set</a> was first released for the <a href="http://www.appsforamsterdam.nl/">Apps for Amsterdam</a> 2011 contest.</p>
<p>The <a href="http://www.imergis.nl/shp/2012-Veiligheidsregios-watergrenzen-Shp.zip">boundaries</a> of the Joint Emergency Services Districts (<span lang="nl">veiligheidsregio's</span>) have been obtained from <a href="http://www.imergis.nl/">Imergis</a>.</p>
<p>This visualisation was created by <a href="http://www.twitter.com/emacgillavry">Edward Mac Gillavry</a> from <a href="http://www.webmapper.net/">Webmapper</a> using <a href="http://www.cartodb.com/">CartoDB</a> and <a href="https://github.com/CartoDB/torque">Torque</a>.</p>
<p>Learn more about how we converted the data <a href="http://webmapper.net/lab/fire-engine-callouts-part-1-from-csv-to-geojson/">from <abbr title="Comma Separated Value">CSV</abbr> to GeoJSON</a> and <a href="http://webmapper.net/lab/fire-engine-callouts-part-2-animated-map-with-torque/">created the animated map</a>.</p>
<a href="http://www.webmapper.net/">
<img src="http://www.webmapper.net/theme/img/wm-logo.png" class="logo" alt="Webmapper" width="135" height="60" title="What the map can be"/>
</a>
</header>
<div id="toggle-button"></div>
<div id="twitter-button"><a href="http://twitter.com/share?url=http://emacgillavry.github.io/callouts/&text=Check+out+this+animated+map+of+fire+engine+callouts+in+Amsterdam&via=webmappery" class="twitter-share-button">Tweet this!</a></div>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<footer>
<a class="cartodb_logo" href="http://www.cartodb.com" target="_blank">CartoDB</a>
</footer>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script src="lib/leaflet-hash.js"></script>
<script src="lib/underscore.js"></script>
<script src="lib/carto.js"></script>
<script src="lib/torque.js"></script>
<script>
L.TopoJSON = L.GeoJSON.extend({
addData: function(jsonData) {
if (jsonData.type === "Topology") {
for (key in jsonData.objects) {
var geojson = topojson.feature(jsonData, jsonData.objects[key]);
L.GeoJSON.prototype.addData.call(this, geojson);
}
} else {
L.GeoJSON.prototype.addData.call(this, jsonData);
}
}
});
document.getElementById('torque_time').innerHTML = "Loading data...";
$(function () {
var torqueTime = $('#torque_time');
var bg_map = L.tileLayer('http://a{s}.acetate.geoiq.com/tiles/acetate-hillshading/{z}/{x}/{y}.png', {
attribution: 'Basemap design by <a href="http://www.stamen.com/">Stamen</a>. Tiles hosted by <a href="http://www.geoiq.com/">GeoIQ</a>. Map data: <a href="http://www.openstreetmap.org/">OpenStreetMap</a> contributors and <a href="http://www.naturalearthdata.org/">Natural Earth Data</a>.',
subdomains: '0123',
minZoom: 2,
maxZoom: 18
});
var torqueLayer = new L.TorqueLayer({
provider : 'sql_api',
user : 'emacgillavry',
table : 'callouts',
column : 'starttime',
countby : 'count(cartodb_id)',
resolution : 2,
is_time : true,
steps : 750,
blendmode : 'source-over',
animationDuration: 60
});
var DEFAULT_CARTOCSS = [
'#layer {',
' marker-width: 2;',
' marker-fill: #FEE391; ',
' [value > 2] { marker-fill: #FEC44F; }',
' [value > 3] { marker-fill: #FE9929; }',
' [value > 4] { marker-fill: #EC7014; }',
' [value > 5] { marker-fill: #CC4C02; }',
' [value > 6] { marker-fill: #993404; }',
' [value > 7] { marker-fill: #662506; }',
' [frame-offset = 1] { marker-width: 10; marker-fill-opacity: 0.05;}',
' [frame-offset = 2] { marker-width: 20; marker-fill-opacity: 0.02;}',
'}'
].join('\n');
torqueLayer.setCartoCSS(DEFAULT_CARTOCSS);
var map = new L.Map('map_canvas', {
zoomControl: true,
center: [52.37653577,4.88750188],
zoom: 11,
layers: [bg_map,torqueLayer]
});
var hash = new L.Hash(map);
torqueLayer.on('change:time', function(changes) {
if (changes.time.toString() != 'Invalid Date') {
var month_year = changes.time.toString().substr(4).split(' ');
torqueTime.text(month_year[0] + " " + month_year[2]);
}
});
torqueLayer.play();
$.getJSON('data/veiligheidsregios.topojson', function(jsondata) {
var polys = new L.TopoJSON(jsondata, {
style: {weight: 2, color: "#fff", fillOpacity: 0}
});
polys.addTo(map);
});
torqueLayer.addTo(map);
$('#toggle-button').click(function() {
$('header').toggle();
$('#toggle-button').toggleClass("closed");
});
});
</script>
</body>
</html>