CartodbJS heatmap
by jsanz
HTML
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css">
<script src="http://www.maps.google.com/maps/api/js?sensor=false&v=3.12"></script>
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script>
<div id='map'></div>
CSS
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
JavaScript
var map = L.map('map', {
zoomControl: true,
center: [35.18727767598896, -82.36587524414062],
zoom: 9
});
var basemap = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>'
}).addTo(map);
var layerUrl = 'https://dchadney.cartodb.com/api/v2/viz/a5d55fa4-3f73-11e5-b773-0e4fddd5de28/viz.json';
cartodb.createLayer(map, layerUrl)
.addTo(map)
.on('done', function (layer) {
setTimeout(function(){
console.log('hide');
layer.hide();
}, 2000);
setTimeout(function(){
console.log('show');
layer.show();
layer.redraw(); // this is needed to update the layer
}, 3000);
})