【发布时间】:2013-10-11 18:31:07
【问题描述】:
我正在使用 Google Maps/Places javascript API 来自动完成输入框中的位置。我正在尝试限制自动完成返回的地点类型。我对coffeescript(以及一般的编码)非常陌生,但是由于我在这里有代码sn-p,我想看看是否有人可以在此代码中看到任何可能导致对Google的调用不考虑该位置的内容“类型”过滤器。请注意,“restaurants”只是用作测试(不成功的测试)。
我已经阅读了这里的其他几个问题,其中包括: How can I restrict the Google Maps Places Library's Autocomplete to suggestions of only one city's places? How to limit google autocomplete results to City and Country only
不幸的是,看起来我使用的语法是正确的,这就是我问这个问题的原因,因为无论我使用哪种“类型”,自动完成结果都不会改变。
感谢您的帮助。
# autocomplete callback
autocomplete_options = {
types: ['restaurants'] # geocode, establishment, (regions), (cities)
}
autocomplete = new google.maps.places.Autocomplete(document.getElementById 'locationSearchField', autocomplete_options)
google.maps.event.addListener autocomplete, 'place_changed', ->
place = autocomplete.getPlace()
【问题讨论】:
标签: google-maps-api-3 autocomplete coffeescript google-places-api