Heatmap.js not rendering
http://stackoverflow.com/questions/20384017/heatmap-js-not-rendering
HTML
<script src="https://rawgit.com/pa7/heatmap.js/master/build/heatmap.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="https://cdn.rawgit.com/pa7/heatmap.js/develop/plugins/gmaps-heatmap.js"></script>
<div id="heatmapArea"></div>
CSS
div#heatmapArea {
width:1024px;
padding:0;
height:768px;
cursor:pointer;
position:relative;
}
JavaScript
// standard gmaps initialization
var myLatlng = new google.maps.LatLng(43.46811941, -71.06360000);
// define map properties
var myOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: false,
scrollwheel: true,
draggable: true,
navigationControl: true,
mapTypeControl: false,
scaleControl: true,
disableDoubleClickZoom: false
};
// we'll use the heatmapArea
var map = new google.maps.Map($("#heatmapArea")[0], myOptions);
// let's create a heatmap-overlay
// with heatmap config properties
var heatmap = new HeatmapOverlay(map, {
// radius should be small ONLY if scaleRadius is true (or small radius is intended)
"radius": 2,
"maxOpacity": 1,
// scales the radius based on map zoom
"scaleRadius": true,
// if set to false the heatmap uses the global maximum for colorization
// if activated: uses the data maximum within the current map boundaries
// (there will always be a red spot with useLocalExtremas true)
"useLocalExtrema": true,
// which field name in your data represents the latitude - default "lat"
latField: 'lat',
// which field name in your data represents the longitude - default "lng"
lngField: 'lng',
// which field name in your data represents the data value - default "value"
valueField: 'count'
});
// here is our dataset
// important: a datapoint now contains lat, lng and count property!
var testData = {
max: 1.0,
data : [{lat: 42.35810000, lng:-71.06360000, count:0.3},
{lat: 42.82995815, lng:-74.78991444, count:0.4},
{lat: 43.17929819, lng:-78.56603306, count:0.5},
{lat: 43.40320216, lng:-82.37774519, count:0.6},
{lat: 43.49975489, lng:-86.20965845, count:0.7},
{lat: 43.46811941, lng:-90.04569087, count:0.8},
]};
heatmap.setData(testData);