Skip to content

Instantly share code, notes, and snippets.

@iriberri
Last active August 29, 2015 14:07
Show Gist options
  • Save iriberri/35c0f8722faf4f5fad56 to your computer and use it in GitHub Desktop.
Save iriberri/35c0f8722faf4f5fad56 to your computer and use it in GitHub Desktop.
Customize time-slider via CSS
<!DOCTYPE html>
<html>
<head>
<title>Easy 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/themes/css/cartodb.css" />
<style>
div.cartodb-timeslider {
left:10px!important;
right:10px!important;
height:50px;
}
li.controls,
li.time {
position:absolute;
top:-5px;
border:none!important;
z-index:10;
}
li.controls {
left:50%;
margin-left:-50px;
}
li.time {
left:50%;
margin-right:-50px;
}
div.cartodb-timeslider li.last {
position:absolute;
left:15px;
right:15px;
z-index:2;
}
div.cartodb-timeslider .slider-wrapper {
position:absolute;
left:0;
right:0;
width:100%;
padding:30px 0 15px;
}
</style>
</head>
<body>
<div id="map"></div>
<!-- include cartodb.js library -->
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.js"></script>
<script>
function main() {
var map = new L.Map('map', {
zoomControl: false,
center: [43, 0],
zoom: 3
});
L.tileLayer('http://tile.stamen.com/toner/{z}/{x}/{y}.png', {
attribution: 'Stamen'
}).addTo(map);
// create a layer with 1 sublayer
cartodb.createLayer(map, 'http://team.cartodb.com/api/v2/viz/1cf4e082-a08c-11e4-b964-0e0c41326911/viz.json', { legends: false }).done(function(layer) {
// add the layer to our map which already contains 1 sublayer
map.addLayer(layer);
});
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment