これをクロージャ内でsettimeout関数を使用して表現すると、APIを実行する前後に2秒の一時停止を作成できます。 geocoder.geocodeは非同期であることに注意してください。settimeout関数を使用したjavascriptクロージャ
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{
}
});
}
}
理由:繰り返しサードパーティのAPIのを呼び出すときに、それが必要な時に、スロットル要求に丁寧です。 –