역 지오 코딩을 사용하여 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.");
}
});
많은 분들께 미리 감사드립니다.
'getCity()'이 호출되지 않는 순간에'geocoder'가 정의되지 않고'geocoder.geocode()'가 실패하기 때문에 모든 코드가 될 수는 없습니다. –
더 많은 코드, 페이지 링크 또는 jsFiddle 페이지를 설정해야 할 수 있습니다. 나는'codeLatLng' 함수 내에서 루프를 보지 못했다. 지오 코더가 루프에서 호출되는 방식을 볼 수 없습니다. –