I want to get Latitude and Longitude of a set of addresses.This is the code I used.
var marker_array = [];
//Event detail array
var LiveEventDetails= <?php echo json_encode($liveEventsDetails); ?>;
LiveEventDetails.forEach(function(event) {
geocoder.geocode({ 'address': event.venue }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK)
{
marker_array.push([results[0].geometry.location.A,results[0].geometry.location.F]);
}
//1st test
console.log(marker_array);
});
// 2nd test
console.log(marker_array);
});
//3rd test
console.log(marker_array);
the output(marker_array) given by the first console.log() has the pushed data in it.. But after the geocoder function marker_array is shown as empty by the 2nd and third console.log();
How can I keep the pushed array after the geocoder function without being empty..