Loading in data from a json file and trying to use it outside of this function
function loadJSON() {
//load location info into array to be used by positions/colors/size loop
$.getJSON('lib/js/data/brand.json', function(data) {
for ( var j = 0; j < data[0].locations.length; j++ ) {
var point = {}; // New point object
point.id = (data[0].locations[j].brand) + j; // Brand name + id
point.lat = (data[0].locations[j].lat); // lat property
point.long = (data[0].locations[j].long); // long property
points.push(point);
}
});
}
when I call the functioin and try to reference a point, it's undefined
loadJSON();
console.log(points[0]);
if I just console.log(points), I get something like this
[]
0
:
{id: "arbys0", lat: "39.1031", long: "-84.512"}
1
:
{id: "arbys1", lat: "39.1031", long: "-84.512"}