Skip to content

Instantly share code, notes, and snippets.

@jlivni
Forked from javisantana/index.html
Last active August 29, 2015 14:27
Show Gist options
  • Save jlivni/a1c415b7421a56cdba05 to your computer and use it in GitHub Desktop.
Save jlivni/a1c415b7421a56cdba05 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Leaflet multilayer example | CartoDB.js</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" />
</head>
<body>
<div id="map"></div>
<!-- include cartodb.js library -->
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script>
<script>
function main() {
// create leaflet map
var map = L.map('map', {
zoomControl: false,
center: [43, 0],
zoom: 3
})
// add a base layer
L.tileLayer('http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png',{
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, &copy; <a href="http://cartodb.com/attributions">CartoDB</a>'
}).addTo(map);
// add cartodb layer with one sublayer
cartodb.createLayer(map, {
user_name: 'viz2',
type: 'torque',
options: {
query: 'select * from ow',
cartocss: ['Map {',
'-torque-frame-count:1;',
'-torque-animation-duration:10;',
'-torque-time-attribute:"cartodb_id";',
'-torque-aggregation-function:"count(cartodb_id)";',
'-torque-resolution:8;',
'-torque-data-aggregation:linear;',
'}',
'',
'#out_3{',
'image-filters: colorize-alpha(blue, cyan, lightgreen, yellow , orange, red);',
'marker-file: url(http://s3.amazonaws.com/com.cartodb.assets.static/alphamarker.png);',
'marker-fill-opacity: 0.01*[value];',
'marker-width: 25;',
'}'].join('\n')
}
})
.addTo(map)
.done(function(layer) {
});
}
// you could use $(window).load(main);
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment