My application retrieves addresses from a file that is updated every few hours, geocodes them, and displays them on Google Maps.
Despite implementing a 2-second delay between each query and not using the application since the previous day, I am encountering an OVER_QUERY_LIMIT error. The code below is executed when the corresponding function is called, which occurs 2 seconds after its previous invocation.
var xmlhttp
var status;
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
var lAddress = tAddress.replace(/ /g, " +");
xmlhttp.open("GET","http://maps.googleapis.com/maps/api/geocode/json?address=" + lAddress +"&sensor=false", false);
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
var result = JSON.parse(xmlhttp.responseText);
status = result.status;
if(status == google.maps.GeocoderStatus.OK){
precise[index].found = 1;
precise[index].lat= result.results[0].geometry.location.lat;
precise[index].lng = result.results[0].geometry.location.lng;
precise[index].addr = tAddress;
}
else if(status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT){
alert("The search limit has been exceeded. Please try again tomorrow.");
}
}
}
xmlhttp.send();