Skip to content Skip to sidebar Skip to footer

TypeError: B.lat Is Not A Function - Heatmap Layer

I'm stuck trying to figure out why I'm getting the above issue for my heat-layer. The answers I've seen on while seatching address improper LatLng setup, however my marker's LatLng

Solution 1:

The HeatmapLayer is one of the remaining places you can't use a google.maps.LatLngLiteral for a position, it must be a google.maps.LatLng object. (the error you get is because the anonymous object LatLngLiteral doesn't have a .lat() method, it has a .lat property).

Change:

for (var i = 0; i < resultSet.length; i++) {
    labels.push(resultSet[i][0]);
    locations.push({
        lat: parseFloat(resultSet[i][3]),
        lng: parseFloat(resultSet[i][4])
    });
    if (data[0] == '1') {
        var marker = new google.maps.Marker({
            position: locations[i],
            map: map,
            title: labels[i]
        });
        marker.setMap(map);
    }
}

To:

for (var i = 0; i < resultSet.length; i++) {
    labels.push(resultSet[i][0]);
    locations.push(new google.maps.LatLng(
        parseFloat(resultSet[i][3]),
        parseFloat(resultSet[i][4])
    ));
    if (data[0] == '1') {
        var marker = new google.maps.Marker({
            position: locations[i],
            map: map,
            title: labels[i]
        });
        marker.setMap(map);
    }
}

Post a Comment for "TypeError: B.lat Is Not A Function - Heatmap Layer"