Reputation: 2527
How can I express this within a closure with a settimeout function to create a 2 second pause before or after running the API. Note that geocoder.geocode is asynchronous.
function srPerformGeocode(addressToArray, nextRecord){
var address = addressToArray.join(",");
console.log(address);
if (geocoder){
glDelay = true;
geocoder.geocode({ 'address': address.trim() }, function
(results, status) {
// count number of geocodings attempted
glGeocodeCount ++;
if (status == google.maps.GeocoderStatus.OK){
}
else{
}
});
}
}
Upvotes: 0
Views: 524