Skip to content

Instantly share code, notes, and snippets.

@desireesantos
Created December 26, 2013 16:57
Show Gist options
  • Save desireesantos/8135997 to your computer and use it in GitHub Desktop.
Save desireesantos/8135997 to your computer and use it in GitHub Desktop.
Js file responsible to generate heatmap
var map,heatmap;
var taxiData = new Array();
var gradient = [
'rgba(0, 255, 255, 0)','rgba(0, 255, 255, 1)',
'rgba(0, 191, 255, 1)','rgba(0, 127, 255, 1)',
'rgba(0, 63, 255, 1)','rgba(0, 0, 255, 1)',
'rgba(0, 0, 223, 1)','rgba(0, 0, 191, 1)',
'rgba(0, 0, 159, 1)','rgba(0, 0, 127, 1)',
'rgba(63, 0, 91, 1)','rgba(127, 0, 63, 1)',
'rgba(191, 0, 31, 1)','rgba(255, 0, 0, 1)'
]
function initialize() {
var mapOptions = {
zoom: 4,
center: new google.maps.LatLng(-8.754795,-55.045897),
mapTypeId: google.maps.MapTypeId.HYBRID
};
map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
carregarPontos();
var pointArray = new google.maps.MVCArray(taxiData);
heatmap = new google.maps.visualization.HeatmapLayer({
data: pointArray
});
heatmap.setMap(map);
heatmap.set('radius', 10);
heatmap.set('gradient', gradient);
}
function carregarPontos() {
$.getJSON("/template/data.json", function(casesOfDengue) {
$.each(casesOfDengue, function(index, dengue) {
taxiData.push(new google.maps.LatLng(dengue.latitude, dengue.longitude));
});
});
}
google.maps.event.addDomListener(window, 'load', initialize);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment