Google 地点自动完成未返回正确的地点

Google places autocomplete is not returning correct places

我遵循了以下教程:

https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform

并且,我编写的结果代码具有以下 google 位置自动完成的实例化(我将 Node.js 与 browserify 一起使用,因此它看起来有点不同):

enableAutoCompleteForElement: function(aDomElement) {
    var self = this;

    // The geocode type restricts the search to geographical location types.
    GoogleMapsLoader.KEY = ArbitratorConfig.google_api_key;
    GoogleMapsLoader.LIBRARIES = ['places'];
    GoogleMapsLoader.SENSOR = false;

    console.log("Google client id: " + ArbitratorConfig.google_client_id);

    GoogleMapsLoader.load(function(google) {
      self.autocomplete = new google.maps.places.Autocomplete(aDomElement,
                                                              { types: ['geocode'] });
      google.maps.event.addListener(self.autocomplete, 'place_changed', function() {
        // When the user selects an address from the dropdown, this will fire.
        var place = self.autocomplete.getPlace();
      });
    });
  }

这对于大多数应用程序来说效果很好。但是,我注意到它不如 Google 日历捆绑的地点自动完成准确。例如,如果我在 Google 日历中创建一个事件并在位置输入中搜索 'Bloomington Ice Garden',它将(可能取决于您开始的位置)return 结果'Bloomington Ice Garden, West 98th Street, Minneapolis, MN, United States'。但是,如果我对我的客户执行相同的搜索,它不会显示此结果。我能得到的最接近的是 'Bloomington, MN, United States'.

我觉得我缺少库的一部分,或者我错误地告诉它做一些它不应该做的事情。我希望能够检索在 Google Places 中注册的任何类型的地点 - 不仅仅是城市、州或国家(这似乎是它目前正在自动完成的内容)。

从您的 Autocomplete 中删除 types: ['geocode'] 选项。这就是导致 Google Places Autocomplete 排除像 'Bloomington Ice Garden' 这样的地方的原因,这是一个机构而不是地理编码。