torque/examples/navy_leaflet.html

59 lines
1.5 KiB
HTML
Raw Normal View History

2013-07-26 19:27:21 +08:00
<html>
<link rel="stylesheet" href="vendor/leaflet.css" />
2013-07-26 19:27:21 +08:00
<style>
#map, html, body {
width: 100%; height: 100%; padding: 0; margin: 0;
}
</style>
<body>
<div id="map"></div>
<script src="vendor/leaflet.js"></script>
<script src="../dist/torque.full.uncompressed.js"></script>
2013-07-26 19:27:21 +08:00
<script>
2013-11-27 18:06:39 +08:00
// define the torque layer style using cartocss
var CARTOCSS = [
'Map {',
2015-08-20 02:34:22 +08:00
'-torque-time-attribute: "cartodb_id";',
2013-11-27 18:06:39 +08:00
'-torque-aggregation-function: "count(cartodb_id)";',
2015-08-20 02:34:22 +08:00
'-torque-frame-count: 1;',
'-torque-animation-duration: 1;',
'-torque-resolution: 16',
2013-11-27 18:06:39 +08:00
'}',
'#layer {',
2015-08-20 02:34:22 +08:00
'-isoline-line-ramp: colorize-alpha(blue, cyan, lightgreen, yellow , orange, red);',
'-isoline-line-width: 0.4;',
'-isoline-line-opacity: 0.5',
2013-11-27 18:06:39 +08:00
'}'
].join('\n');
2013-07-26 19:27:21 +08:00
var map = new L.Map('map', {
zoomControl: true,
2015-08-20 02:34:22 +08:00
center: [41.36031866306708, -73.388671875],
zoom: 4
2013-07-26 19:27:21 +08:00
});
2015-08-20 02:34:22 +08:00
L.tileLayer('http://{s}.api.cartocdn.com/base-light/{z}/{x}/{y}.png', {
2013-11-27 18:06:39 +08:00
attribution: 'CartoDB'
2013-07-26 19:27:21 +08:00
}).addTo(map);
var torqueLayer = new L.TorqueLayer({
2015-08-20 02:34:22 +08:00
user : 'fdansv',
table : 'twitter_roosterteeth_roosterteeth_lege',
2013-11-27 18:06:39 +08:00
cartocss: CARTOCSS
2013-07-26 19:27:21 +08:00
});
torqueLayer.error(function(err){
for(error in err){
console.warn(err[error]);
}
});
2013-07-26 19:27:21 +08:00
torqueLayer.addTo(map);
2013-11-27 18:06:39 +08:00
torqueLayer.play()
2013-07-26 19:27:21 +08:00
</script>
</body>
</html>