Google maps api 3 谷歌地图-状态代码-GeocoderStatus

Google maps api 3 谷歌地图-状态代码-GeocoderStatus,google-maps-api-3,google-geocoder,Google Maps Api 3,Google Geocoder,我和geocoderStatus之间有麻烦,基本上我总是得到google.maps.geocoderStatus.OK 当我发送请求时,即使地址无效或结果为零 这是我的密码 if (status == google.maps.GeocoderStatus.OK) { var lat = results[0].geometry.location.lat(); var lon = results[0].geometry.location.lng();

我和geocoderStatus之间有麻烦,基本上我总是得到google.maps.geocoderStatus.OK 当我发送请求时,即使地址无效或结果为零

这是我的密码

    if (status == google.maps.GeocoderStatus.OK) {
        var lat = results[0].geometry.location.lat();
        var lon = results[0].geometry.location.lng();
        searchStores(lat, lon);
    } else {
        $addressErrorP.removeClass('hide');
    }
例如: 如果我把这个地址寄到冷泉路1525号,我能得到这个地址吗

纬度=38.746431,经度=120.86995890000003,这是可以的

如果我把它作为地址$^%$^%%%%$%发送,我会得到:

33.778175&经度=76.57617140000002,这是不存在的 '41.4%22N+76%C2%B034'34.2%22W/@33.778175,-76.5761714,17z/数据=!3m1!4b1!4m2!3m1!1s0x0:0x0?hl=en

所以我需要知道的是,当结果为零时,显示一条错误消息,并且不重新加载无处位置的页面,但我永远不会得到其他状态OK的东西

这是中的文档:

状态代码

状态代码可能返回以下值之一:

google.maps.GeocoderStatus.OK表示地理编码成功。 google.maps.GeocoderStatus.ZERO_结果表明地理代码成功,但未返回任何结果。如果向地理代码传递了不存在的地址或远程位置的latng,则可能会发生这种情况。 google.maps.GeocoderStatus.OVER_QUERY_LIMIT表示您超出了配额。有关更多信息,请参阅GoogleMapsAPI中关于工作文档的文章,该文章也适用于非商业用户。 google.maps.GeocoderStatus.REQUEST_DENIED表示您的请求因某种原因被拒绝。
google.maps.GeocoderStatus.INVALID_请求通常表示缺少查询地址或latLng。

您如何调用geocoder?我得到的$^%$^%%%%$%结果为零。请提供一个示例,其中显示了当您输入垃圾地址时,您得到OK,并且您认为应该获得不同的状态。Ohhh这很有趣:如果我运行此代码测试。地理代码{‘地址’:$%^$%^$^%},functionresults,状态{console.logstatus;};在控制台中,我没有得到任何结果,但在我的JS中,它不起作用,我将对我的代码进行Troubleshoot以查看错误。这真的很奇怪,我正在控制台中测试,结果是:test.geocode{'address':$%%$%%$%%$%%$%%,'region':'usa','componentRestrictions':{'country':'US'},functionresults,status{console.logaddress:,status;};'componentRestrictions':{'country':'US'}似乎正在破坏我的代码,有人知道我可以将搜索限制在美国吗?