Okay, so I have searched a while for a solution to this problem, but I have found nothing specifically on this. And before you point me to Google\'s Terms of Service, pleas
This is a FAQ. Geocoding is asynchronous. You need to save the results in the callback function which runs when they are returned from the server.
Something like (not tested)
Updated to use function closure
function geocodeAddress(address, i) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latLong = results[0].geometry.location;
coordinates = latLong.lat() + "," + latLong.lng();
adressdaten[i][6] = coordinates;
} else {
alert('Geocode of '+address+' was not successful for the following reason: ' + status);
}
});
}
var geocoder = new google.maps.Geocoder();
for (i=1; i<adressdaten.length-1; i++) {
//Save array-data in String to pass to the Geocoder
var adresse = adressdaten[i][3] + " " + adressdaten[i][4];
var coordinates;
geocodeAddress(addresse, i);
}