I have data like this:
"meta":{"About thisdata"}, "objects": [{"beat": "1614", "block": "081XX W HIGGINS RD", "case_number": "JA100466", "classification": "/api/1.0-beta3/crimeclassification/83/", "community_area": "/api/1.0-beta3/communityarea/10/", "community_name": "Norwood Park", "community_number": 10, "community_slug": "norwood-park", "crime_date": "2016-12-30T18:00:00", "description": "$500 AND UNDER", "domestic": false, "fbi_code": "06", "id": "10801504", "iucr": "0820", "latitude": 41.985421498, "location_description": "STREET", "longitude": -87.829756604, "primary_type": "THEFT", "ward": 41, "year": 2016},
In total this will have 500 objects under "objects"
I am trying to create 500 of these: new google.maps.LatLng(37.782551, -122.445368)
to put in an array like this:
function getPoints() {
return [
new google.maps.LatLng(37.782551, -122.445368),
new google.maps.LatLng(37.782745, -122.444586),
new google.maps.LatLng(37.782842, -122.443688)
]
}
to be returned here:
function initMap () {
map = new google.maps.Map(document.getElementById("map"), {
center: { lat: 41.881, lng: -87.629 },
zoom: 12,
mapTypeId: 'satellite'
});
heatmap = new google.maps.visualization.HeatmapLayer({
data: makeMarkers(), <-- Here
map: map
});
}
The code I have tried look like this:
var makeMarkers = function () {
var result = [];
var lat, lng = [];
resp.objects.forEach(function(objects) {
lat.objects.latitude;
lng = objects.longitude;
return [new google.maps.LatLng(lat, lng)]
})
}
but instead of returning an array of new objects, it returns 500 new arrays with one google object because it's inside the forEach. I'm not sure how to get what I'm looking for. I struggle a fair amount with scopes and iterating through data.
Thank you!