75 lines
2.5 KiB
HTML
75 lines
2.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head lang="en">
|
|
<meta charset="UTF-8">
|
|
<title>CartoDb Torque Layer Example</title>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.17.1/ol.css" type="text/css">
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.17.1/ol.js"></script>
|
|
<style>
|
|
#map, html, body {
|
|
width: 100%; height: 100%; padding: 0; margin: 0;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="map"></div>
|
|
<script src="https://libs.cartocdn.com/torque.js/2.16.5/torque.full.js" type="application/javascript" charset="utf-8"></script>
|
|
|
|
|
|
<script>
|
|
// define the torque layer style using cartocss
|
|
var CARTOCSS = [
|
|
'Map {',
|
|
'-torque-time-attribute: "date";',
|
|
'-torque-aggregation-function: "count(cartodb_id)";',
|
|
'-torque-frame-count: 760;',
|
|
'-torque-animation-duration: 15;',
|
|
'-torque-resolution: 2',
|
|
'}',
|
|
'#layer {',
|
|
' marker-width: 3;',
|
|
' marker-fill-opacity: 0.8;',
|
|
' marker-fill: #FEE391; ',
|
|
' comp-op: "lighten";',
|
|
' [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: 15; marker-fill-opacity: 0.02;}',
|
|
'}'
|
|
].join('\n');
|
|
|
|
var map = new ol.Map({
|
|
target: "map",
|
|
view: new ol.View({
|
|
center: [40, 0],
|
|
zoom: 3
|
|
}),
|
|
layers: [
|
|
new ol.layer.Tile({
|
|
source: new ol.source.XYZ({ url: 'https://basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png'})
|
|
})
|
|
],
|
|
interactions: ol.interaction.defaults({
|
|
dragPan: false
|
|
}).extend([
|
|
new ol.interaction.DragPan({kinetic: false})
|
|
])
|
|
});
|
|
|
|
var torqueLayer = new ol.TorqueLayer({
|
|
user : 'viz2',
|
|
table : 'ow',
|
|
cartocss: CARTOCSS,
|
|
tiler_protocol: 'https',
|
|
tiler_port: 443
|
|
});
|
|
|
|
torqueLayer.onAdd(map);
|
|
torqueLayer.play()
|
|
</script>
|
|
</body>
|
|
</html> |