GoogleMaps geocoder error: ZERO_RESULTS

此生再无相见时 提交于 2020-01-03 03:22:23

问题


This is my JS code to get lon and lat of an address.

in 99% of the time it works OK.... but sometimes I get ZERO_RESULTS status...

if (geocoder) {
    geocoder.geocode({'address': address, 'language':'it'}, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            $('#frm_company_lat').val(results[0].geometry.location.lat());
            $('#frm_company_lon').val(results[0].geometry.location.lng());

            can_submit = true;
            $('#company_frm').trigger("submit");
        } else{
            top.console.debug(address);
            top.console.debug(status);
            alert("Cannot get lon in lat: "+ address);
            //can_submit = true;
            //$('#company_frm').trigger("submit");
        }
    });
}

The address is nothing special and if I look for it in google maps directly, it shows...

If I try to fetc JSON directly (via direct url) I get the same result!

http://maps.googleapis.com/maps/api/geocode/xml?address=Via%20Selo%2010a,%2047122%20Forli,%20Italia&sensor=false

PLEASE ADVISE


回答1:


It looks like sometimes is better to remove the postal number/zip out of the address query...

so in the specific case if I remove 47122 it works OK.



来源:https://stackoverflow.com/questions/13956615/googlemaps-geocoder-error-zero-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!