2012-05-13 2 views
2

역 지오 코딩을 사용하여 4 개의 양식 필드를 채 웁니다. 양식이 올바르게 채워지지만 OVER_QUERY_LIMIT이라는 오류가 표시됩니다. JS 콘솔에서 크롬을 검사 할 때 오류 메시지가 나타나기 전에 다섯 번의 동일한 호출이 수행 된 것을 볼 수 있습니다. 내 코드가 여러 요청을하는 이유가 확실하지 않습니다. 누군가가 codeLatLng 함수의 루프에서 변경해야하는 것을 지적 해 주시겠습니까? 문제가있는 부분은 그럴 가능성이 큽니다.over_query_limit으로 인해 Google 지오 코더 오류가 발생했습니다.

var geocoder; 

function getCity() { 
    geocoder = new google.maps.Geocoder(); 
    } 


    if (navigator.geolocation) { 
    navigator.geolocation.getCurrentPosition(successFunction, errorFunction); 
} 
//Get the latitude and the longitude; 
function successFunction(position) { 
    var lat = position.coords.latitude; 
    var lng = position.coords.longitude; 
    //alert("Success funciton" + lat + " " + lng); 
    codeLatLng(lat, lng)  
} 

function errorFunction(){ 
    AppMobi.notification.alert("For the best user experience, please ensure your device GPS and geolocation settings are enabled.","Geolocation disabled","OK"); 
} 

    function codeLatLng(lat, lng) { 
    //alert("codeLatLng fn started"); 
    var latlng = new google.maps.LatLng(lat, lng); 
    geocoder.geocode({'latLng': latlng}, function(results, status) { 
     if (status == google.maps.GeocoderStatus.OK) { 
     console.log(results) 
     if (results[1]) { 
     //formatted address 
    //alert(results[0].formatted_address) //Complete address 
    $("#address1").val(results[0].formatted_address); 
    } else { 
     alert("No results found. Please enter the data manually."); 
    } 
    } else { 
    alert("Geocoder failed due to: " + status +". Please enter the data manually."); 
    } 
}); 

많은 분들께 미리 감사드립니다.

+0

'getCity()'이 호출되지 않는 순간에'geocoder'가 정의되지 않고'geocoder.geocode()'가 실패하기 때문에 모든 코드가 될 수는 없습니다. –

+0

더 많은 코드, 페이지 링크 또는 jsFiddle 페이지를 설정해야 할 수 있습니다. 나는'codeLatLng' 함수 내에서 루프를 보지 못했다. 지오 코더가 루프에서 호출되는 방식을 볼 수 없습니다. –

답변

3

Google Maps API 웹 서비스의 사용에는 허용되는 일일 요청 량에 대한 특정 제한이 있습니다.

OVER_QUERY_LIMIT는이 제한 때문에 발생합니다.

여기에 더 많은 정보를 찾을 수 있습니다

https://developers.google.com/maps/documentation/business/articles/usage_limits

당신은 구글이 오류로 응답 할 때의 setTimeout, 예를 들어, 이상 2 초 대기 시도 할 수 있습니다.

결과 [0] .address_components [i]가 함수 호출에 대한 참조가 될 수 있습니다.

+0

안녕하십니까. 나는 Google의 끝에서 제한을 이해합니다. 내 코드에서 여러 요청을 일으키는 요소를 식별 할 수 없습니다 (한 요청 만하고 싶습니다!). 의견을 읽은 후 결과 [0] .address_components [i]를 완전히 주석 처리했습니다. 대신 폼 필드 (예 : 123 Fake Ave., SomeCity, SomeState, SomeCountry)의 주소로 하나의 긴 텍스트 묶음을 입력하십시오. 그러나 여전히 동일한 오류가 표시됩니다. : .. 다른 제안 사항은 무엇입니까? – M4bhat

+0

새 코드에는 아무 것도 표시되지 않습니다. (모두 간단하게 geocoder.geocode를 호출하고 다른 모든 코드와 구분하여 사용하는 것이 좋습니다. 일부 지오 코드 함수 (변수)를 재정의 하시겠습니까? – TlmaK0

관련 문제