Hi, I need some help please,I am trying to reverse geocoding the lat and lng points.
but i am having problem when the geocode returned the status “OVER_QUERY_LIMIT”,I want the delay to increase the time and i want that to perform again the reverese geocode so that i can get the address…can you help me please.
Thank you in advance.
var idx;
var mydata;
var delay=100;
var reverseaddress=[];
$(function(){
$.ajax({
....
....
success:function(data)
mydata = data;
controller();
});
});
function decodeAddress(idx){
latlng = new google.maps.LatLng(mydata.lat[idx],mydata.lng[idx]);
geocoder.geocode({latLng:latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
reverseaddress.push(results[0].formatted_address);
} else {
console.log("no result found");
}
} else {
if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
idx--;
delay++;
} else {
var reason="Code "+status;
var msg = 'address="' + latlng + '" error=' +reason+ '(delay='+delay+'ms)<br>';
console.log("MESSAGE=",msg);
}
}
controller();
});
}
function controller() {
if (idx < datacoord.lat.length) {
setTimeout('decodeAddress("'+idx+'")', delay);
idx++;
} else {
console.log("Finished");
}
}