Heatmap.js not rendering

http://stackoverflow.com/questions/20384017/heatmap-js-not-rendering

by Ben Smith

HTML

<script src="http://www.patrick-wied.at/static/heatmapjs/src/heatmap.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://www.patrick-wied.at/static/heatmapjs/src/heatmap-gmaps.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(48.3333, 16.35);

    // define map properties
    var myOptions = {
        zoom: 3,
        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": 20,
            "visible": true,
            "opacity": 60
    });

    // here is our dataset
    // important: a datapoint now contains lat, lng and count property!
    var testData = {
        max: 3,
        data: [{
            lat: 48.3333,
            lng: 16.35,
            count: 100
        }, {
            lat: 51.465558,
            lng: 0.010986,
            count: 100
        }, {
            lat: 33.5363,
            lng: -5.044,
            count: 100
        }]
    };

    // now we can set the data
    google.maps.event.addListenerOnce(map, "idle", function () {
        // this is important, because if you set the data set too early, the latlng/pixel projection doesn't work
        //debugger;
        heatmap.setDataSet(testData);
    });