2016-12-17 9 views
0

방향 서비스에 대한 여러 요청을 보낼 때 OVER_QUERY_LIMIT에 도달했습니다. 나는 그것이 잘 알려진 문제이며 거기에 요청을 지연하는 몇 가지 해결책이 있지만 나는 그것을 할 수 없다는 것을 알고 내 요청은 php 루프에 보내집니다 beacause.Please 도와주세요! 여기Google지도 방향 요청이 OVER_QUERY_LIMIT (으)로 인해 실패했습니다. - JavaScript 기능 또는 PHP 코드 일시 중지

가 (코드가 잘 내 PHP 코드의 일부 작동되지만 어떤 시점에서 나는 OVER_QUERY_LIMIT 오류 얻을 :

function initMap(Userloc,Actloc1,Actloc2,i) { 


    var renderOptions = {draggable:true}; 

    var directionsDisplay = new google.maps.DirectionsRenderer(renderOptions); 
    var directionsService = new google.maps.DirectionsService; 

    var mapOptions = { 
     zoom: 11, 
     center: {lat:-20.239340, lng:57.574604} 
    }; 

    var map = new google.maps.Map(document.getElementById('map' + i), mapOptions); 

    directionsDisplay.setMap(map); 

    var items = [Actloc1,Actloc2]; 

    var destination; 

    if(Actloc2 == ''){ 

     destination = Actloc1; 
    } 

    else { 

     destination = Actloc2; 
    } 

    var waypoints = []; 

    for (var j = 0; j < items.length; j++) { 

     var address = items[j]; 

     if (address !== '') { 
      waypoints.push({ 
       location: address, 
       stopover: true 
      }); 
     } 
    } 

    directionsService.route({ 

     origin: Userloc, 
     destination: destination, 
     travelMode: 'DRIVING', 
     waypoints: waypoints 

    }, function(response, status) { 
     if (status === 'OK') { 
      directionsDisplay.setDirections(response); 
     } else { 
      window.alert('Directions request failed due to ' + status); 
     } 
    }); 

} 

어떻게 : 여기

for($i=0;$i<count($PlanningArray);$i++){ 

echo"script> 

initMap('$Userlocation','$ActLocation1','$ActLocation2','$DivMapID' 

</script> " 

} 

하는 기능입니다

답변

0

소스를 테스트 할 수 없지만 해결책이있는 것 같습니다. 1 초 이상 기다리십시오. 시도해보십시오.

 if (stripos($ret,"OVER_QUERY_LIMIT")) 
      { 
       echo "<font color=red>OVER_QUERY_LIMIT waiting for 1 sec</font>"; 

       ob_flush(); 
       flush(); 
       sleep(1); 

       ... 
      } 
+0

$ ret는 무엇입니까? –

+0

$ ret는 쿼리의 반환 값이므로 "OVER_QUERY_LIMIT"에 대한 equl을 확인할 수 있습니다. –