I am dealing with this problem in my google maps code but its actually an architectural problem. at some point because of so much request google maps limits the response, and at that point i want to make another request with a delay, but when i call function2 again it says "array is not defined".
function1() {
var array = JSON.parse(xmlhttp.responseText);
for (i; i < length; < i++) {
function2(array[i].one, array[i].two);
}
function3() {
//render directions
}
function2(start, end) {
directionsService.route({
origin: start,
destination: end,
},
function (result, status) {
if (status == google.maps.DirectionsStatus.OK)
function3(result);
else if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT)
var functionStr = "function2(array[i].one" + ',' + "array[i].two)";
setTimeout(functionStr, 5000);
});
}
}