Skip to content

Instantly share code, notes, and snippets.

@jbu
Created August 27, 2014 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbu/0703a0b20ffbf9da3e01 to your computer and use it in GitHub Desktop.
Save jbu/0703a0b20ffbf9da3e01 to your computer and use it in GitHub Desktop.
Heatmap
<html>
<head>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src='http://maps.googleapis.com/maps/api/js?libraries=visualization&sensor=true_or_false'></script>
<script>
$(document).ready(function () {
$.get("https://dl.dropboxusercontent.com/u/26693853/history-07-27-2014.kml", {
dataType: 'xml'
}, function (data) {
var heatmapData = [];
$(data).find("coord").each(function (i, e) {
var h = $(e).html().split(' ');
heatmapData.push(new google.maps.LatLng(parseFloat(h[1]), parseFloat(h[0])));
});
var london = new google.maps.LatLng(51.515, -0.101);
map = new google.maps.Map(document.getElementById('map-canvas'), {
center: london,
zoom: 15,
mapTypeId: google.maps.MapTypeId.STREET
});
var heatmap = new google.maps.visualization.HeatmapLayer({
data: new google.maps.MVCArray(heatmapData),
maxIntensity: 1
});
heatmap.setMap(map);
});
});
</script>
</head>
<body>
<div id='map-canvas'></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment