Pokusao sam na ovaj nacin ali opet nije uspesno a to je da dodam setTimeout kako ne bi prekoracio broj requesta po sekundi i kad naidje prazan box da sistem odmah predje na drugi... ali opet isto:
Kôd:
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) {
//OVDE SE PRESKACE PRAZAN BOX I PRELAZI NA DRUGI
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);
}
//OVDE SE CEKA NA SVAKI NOVI REQUEST
setTimeout(function () {
alert('hello');
}, 3000);
searchIndex++;
if (searchIndex < boxes.length)
findPlaces(boxes,searchIndex);
});
}
E sad zaista ne znam sta je ustvari problem ovde???