2015-04-30 106 views
-1

我正在取笑谷歌地方API,我遇到了奇怪的行为,我不明白Autocomplete。谷歌地图自动完成api与规范不一样

这是我如何使用它:

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()有不确定

这是对象:我不知道什么是错的

this is object

回答

1

当选择一个地方是事件触发'place_changed',而你的示例使用 '地方小号 _changed'

尝试:

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