I am implementing the leaflet heatmap on my website and have problems visualising my data in the graph.
The example works by the following test data:
var data = [{
lat: 24.6408,
lng: 46.7728,
count: 3
}, {
lat: 50.75,
lng: -1.55,
count: 1
}, {
lat: 52.6333,
lng: 1.75,
count: 1
}, {
lat: 48.15,
lng: 9.4667,
count: 1
}, {
lat: 52.35,
lng: 4.9167,
count: 2
}, {
lat: 35.5498,
lng: -118.917,
count: 1
}, {
lat: 34.1568,
lng: -118.523,
count: 1
}, {
lat: 27.2498,
lng: -80.3797,
count: 1
}, {
lat: 41.4789,
lng: -81.6473,
count: 1
}, {
lat: 41.813,
lng: -87.7134,
count: 1
}, {
lat: 41.8917,
lng: -87.9359,
count: 1
}, {
lat: 35.0911,
lng: -89.651,
count: 1
}, {
lat: 32.6102,
lng: -117.03,
count: 1
}, {
lat: 41.758,
lng: -72.7444,
count: 1
}, {
lat: 37.5741,
lng: -122.321,
count: 1
}, {
lat: 42.2843,
lng: -85.2293,
count: 1
}, {
lat: 34.6574,
lng: -92.5295,
count: 1
}, {
lat: 41.4881,
lng: -87.4424,
count: 1
}, {
lat: 25.72,
lng: -80.2707,
count: 1
}, {
lat: 34.5873,
lng: -118.245,
count: 1
}, {
lat: 35.8278,
lng: -78.6421,
count: 1
}];
I am trying to get my data via AJAX as follows:
var locationData = [];
$.ajax(heatmapLocationExtraction).done(function(data) {
$.each(data.result, function(key, value) {
locationData.push({
lat: parseFloat(value.address_lat),
lng: parseFloat(value.address_lng),
count: parseInt(value.hitrate)
});
});
});
The data, as I create it, does not get accepted.
When I am doing a console.log on both values, it is represented differents. How do I create the same array of objects as my test data via code?
Please note that I DON'T have a problem with the AJAX call. I have a problem with returning the data in the correct format. The thread suggested as duplicate is not related to the issue I am having.
My console.log statements are placed here:
window.onload = function() {
var testData = {
max: 8,
data: retrieveHeatmapLocationSearchData()
};
console.log(testData.data);
}