【问题标题】:Google maps Autocomplete api not same as specifications谷歌地图自动完成 api 与规范不同
【发布时间】:2015-07-10 02:30:45
【问题描述】:

我在取笑 Google Places API,但我在 Autocomplete 中遇到了我不理解的奇怪行为。

这就是我的使用方式:

const AUTOCOMPLETE_OPTIONS = {
 types: ['address'],
 componentRestrictions: {
    country: 'cz'
 }
};
this.inputPlaceElement = $('#search-around-input')
this.inputPlaceSearchBox = new google.maps.places.Autocomplete(this.inputPlaceElement[0], AUTOCOMPLETE_OPTIONS);
google.maps.event.addListener(this.inputPlaceSearchBox,'places_changed', () => {
  console.log('place change')
})

自动完成输入正常工作,但 place_changed 没有被触发,我尝试了一些东西,从构造函数返回的对象很奇怪。 当我调用方法 getBounds() 或 getPlace() 时,有未定义的

这是对象:我不确定出了什么问题

【问题讨论】:

    标签: google-maps autocomplete google-places-api


    【解决方案1】:

    选择地点时触发的事件是“place_changed”,而您的示例使用“places_changed”

    试试:

    google.maps.event.addListener(this.inputPlaceSearchBox,'place_changed', function() {
      console.log('place change')
    });
    

    【讨论】:

      猜你喜欢
      • 2016-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-31
      • 2014-11-18
      • 2018-03-03
      • 1970-01-01
      • 2014-11-24
      相关资源
      最近更新 更多