Skip to content

Instantly share code, notes, and snippets.

@wboykinm
Created June 22, 2015 17:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wboykinm/3fe8353ec2e92daa5297 to your computer and use it in GitHub Desktop.
Save wboykinm/3fe8353ec2e92daa5297 to your computer and use it in GitHub Desktop.
Map Labels above a CartoDB torque layer
<!DOCTYPE html>
<html>
<head>
<title>Sale Date</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
/* Important for interactivity: */
.leaflet-top-pane {
pointer-events: none;
}
</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() {
var map = new L.Map('map', {
zoomControl: false,
center: [-10, 0],
zoom: 4
});
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);
cartodb.createLayer(map, {
type: "torque",
order: 1,
options: {
query: "",
table_name: "monkey_jump",
user_name: "andrew",
tile_style: '/** torque visualization */ Map { -torque-frame-count:19; -torque-animation-duration:2; -torque-time-attribute:"layer"; -torque-aggregation-function:"count(cartodb_id)"; -torque-resolution:4; -torque-data-aggregation:linear; } #monkey_jump{ comp-op: lighter; marker-opacity: 0.9; marker-line-color: #FFF; marker-line-width: 0; marker-line-opacity: 1; marker-type: ellipse; marker-width: 12; marker-fill: #FF2900; }'
}
}).done(function(layer) {
map.addLayer(layer);
});
// ADD THE REFERENCE OVERLAY (THE TOP OF THE SANDWICH) HERE:
var topPane = L.DomUtil.create('div', 'leaflet-top-pane', map.getPanes().mapPane);
var topLayer = new L.tileLayer('http://{s}.basemaps.cartocdn.com/dark_only_labels/{z}/{x}/{y}.png', {
maxZoom: 17
}).addTo(map);
topPane.appendChild(topLayer.getContainer());
topLayer.setZIndex(7);
}
// 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