Google Maps API v3 Heatmaps Error: "Cannot read property 'HeatmapLayer' of undefined"

I am trying to load a Heatmaps layer onto my google maps, but for some reason I just keep getting the error "Cannot read property 'HeatmapLayer' of undefined."

map = new google.maps.Map(document.getElementById("gmaps"),{
    zoom: 11,
    center: new google.maps.LatLng(39.788403, -86.19990800000001),
    mapTypeControl: false,
    streetViewControl: false,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    panControl: false
});

heatMapData = [
new google.maps.LatLng(39.77745056152344, -86.10900878906250),
new google.maps.LatLng(39.82060623168945, -86.17008972167969),
new google.maps.LatLng(39.77947616577148, -86.17008972167969),
new google.maps.LatLng(39.82987594604492, -86.13955688476562),
new google.maps.LatLng(39.74195098876953, -86.12429046630860)
];
heatmap = new google.maps.visualization.HeatmapLayer({
    data: heatMapData,
    map: map
});

Here is the jsFiddle: http://jsfiddle.net/9HQ2a/3/

Answers


Add the visualization library to the URL when loading the google maps js.

<script async defer src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=visualization"></script>

Need Your Help

What exactly does delegate do in xcode ios project?

iphone objective-c xcode ipad delegates

I have just been learning iPhone apps development but I have a hard time in understanding what delegate actually means? Can anyone tell me with example what it does and how important it is? Thanks ...

Grails 3 - change default port for run-app

grails grails-3.0

In Grails3 grails -Dserver.port=9001 run-app doesn't appear to work: