Skip to content

Instantly share code, notes, and snippets.

@namessanti
Created December 7, 2015 16:35
Show Gist options
  • Save namessanti/4966740e0874356bcd0c to your computer and use it in GitHub Desktop.
Save namessanti/4966740e0874356bcd0c to your computer and use it in GitHub Desktop.
Holiday shopping pedestrian traffic
<!DOCTYPE html>
<html>
<head>
<title>Make amazing maps with CartoDB</title>
<meta name='viewport' content='initial-scale=1.0, user-scalable=no'>
<meta http-equiv='content-type' content='text/html; charset=utf-8'>
<style type='text/css'>
html, body {
border: 0;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
#map {
height: 100%;
background-color: #384047;
}
</style>
<link rel='stylesheet' href='http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css'>
<script src='http://libs.cartocdn.com/cartodb.js/v3/cartodb.js'></script>
</head>
<body>
<div id='map'></div>
<script>
function pad(n, width, z) {
z = z || '0'; n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
function main() {
cartodb.createVis('map', 'https://namessanti.cartodb.com/api/v2/viz/e3faabce-9aca-11e5-a537-0e98b61680bf/viz.json')
.done(function(vis, layers) {
var slider = vis.getOverlay('time_slider');
slider.formatter(function(d) { if(1 == 1){ $('.time .value').css('width','160px');
return pad(d.getMonth()+1,2) +'/'+ pad(d.getDate(),2) +'/'+ d.getFullYear() + ' ' + pad(d.getHours(),2) +':'+pad(d.getMinutes(),2)+':'+pad(d.getSeconds(),2);
}
else {
$('.time .value').css('width','120px');
var day = days[d.getDay()]; return pad(day,9,' ') + ' ' + pad(d.getHours(),2) +':'+pad(d.getMinutes(),2)+':'+pad(d.getSeconds(),2); } }) }) .error(function(err) { console.log(err); }); }
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment