意外结果 - 谷歌自动完成针对约克郡

Unexpected results - Google Autocomplete against yorkshire

本文关键字:克郡 结果 谷歌 意外      更新时间:2023-09-26

我使用谷歌地图自动完成API对'约克郡'得到了意想不到的结果。我已将结果过滤为仅显示英国地区。请帮助我

以下是我在搜索约克郡时得到的结果:

  • 约克郡北部,罗亚姆大学
  • 约克郡东方,雷诺联合
  • 南约克郡,雷诺乌尼多

下面是代码:

<script src="http://maps.google.com/maps?file=api&v=2&key=MYGooGleAPiKey" type="text/javascript"></script><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=places&language=en"></script><script>
$(function() {
    var options = {
        types: ['(regions)'],
        componentRestrictions: {country: 'uk'},
        region: ['(GB)']
    };
    var autocomplete = new google.maps.places.Autocomplete($("#txt_search")[0], options);
    google.maps.event.addListener(autocomplete, 'place_changed', function() {
        var place = autocomplete.getPlace();
        //console.log(place.address_components);
    });
});</script> 

这似乎是 API 中的一个错误,如果您想看到他们修复它,请参阅 https://code.google.com/p/gmaps-api-issues/issues/detail?id=8619 和星号。

在ISO 3166-1 Alpha-2兼容的国家代码规范中,国家"uk"不存在。你用GB试过吗?

检查此链接: http://www.iso.org/iso/home/standards/country_codes/country_names_and_code_elements.htm