Here I have a code to show me google places objects when search in boxes.
So:
function findPlaces(boxes,searchIndex) {
var request = {
bounds: boxes[searchIndex],
types: ["museum"]
};
// alert(request.bounds);
service.nearbySearch(request, function (results, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
alert("Request["+searchIndex+"] failed: "+status);
return;
}
// alert(results.length);
document.getElementById('side_bar').innerHTML += "bounds["+searchIndex+"] returns "+results.length+" results<br>"
for (var i = 0, result; result = results[i]; i++) {
var marker = createMarker(result);
}
searchIndex++;
if (searchIndex < boxes.length)
findPlaces(boxes,searchIndex);
});
}
but if box is empty I get error: Request[i].failed ZERO_RESULT
My first question is How to JUMP over this, so how go to next box and this just jump becouse there is no results
Also some time I get OVER_QUERY_LIMIT - How I can solve this problem?
UPDATE: I TRY LIKE THET TO SOLVE PROBLEM BUT AGAIN IS THE SAME:
function findPlaces(boxes,searchIndex) {
var request = {
bounds: boxes[searchIndex],
types: ["museum"]
};
// alert(request.bounds);
service.nearbySearch(request, function (results, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
//JUMP TO THE NEXT
searchIndex++;
}
// alert(results.length);
document.getElementById('side_bar').innerHTML += "bounds["+searchIndex+"] returns "+results.length+" results<br>"
for (var i = 0, result; result = results[i]; i++) {
var marker = createMarker(result);
}
//WAIT 3000 TO THE NEW REQUEST
setTimeout(function () {
alert('hello');
}, 3000);
searchIndex++;
if (searchIndex < boxes.length)
findPlaces(boxes,searchIndex);
});
}