簡體   English   中英

Google地方信息自動填充功能未返回正確的地方

[英]Google places autocomplete is not returning correct places

我遵循以下教程:

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

並且,我編寫的結果代碼具有以下針對Google Places自動完成功能的實例化(我將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”的位置輸入中進行搜索,它將(可能取決於您的位置)返回“ West 98th Street Bloomington Ice Garden”的結果(美國明尼蘇達州明尼阿波利斯)。 但是,如果我與客戶執行相同的搜索,則不會顯示此結果。 我能得到的最接近的是“美國明尼蘇達州的布魯明頓”。

我覺得我缺少該庫的一部分,或者我錯誤地告訴它去做它不應該做的事情。 我希望能夠檢索在Google地方信息中注冊的所有類型的地點,而不僅僅是城市,州或國家(這似乎是當前自動填寫的地方)。

從您的“ Autocomplete types: ['geocode']刪除types: ['geocode']選項。 這就是導致Google地方信息自動填充功能排除諸如“ Bloomington Ice Garden”之類的場所的原因,該場所是場所而非地理編碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM