【发布时间】:2015-01-07 17:12:24
【问题描述】:
我想限制对纬度/经度的搜索。对于特定地区(即新西兰)。
Google 提供了一些可以设置的参数来实现结果,例如:'componentsRestriction' 和 'region'。我尝试在 config/initializers/geocoder.rb 中设置相同的内容,但没有成功。这是我的代码。
Geocoder.configure(
:lookup => :google,
:timeout => 5,
:units => :km,
# version 1
:google => {
:components => {:country => 'NZ'},
:region => 'NZ',
},
# version 2
:components => {:country => 'NZ'},
:region => 'NZ',
)
这是来自 google 的文档,其中允许指定额外参数,例如用于查找的区域。 https://developers.google.com/maps/documentation/geocoding/
【问题讨论】:
-
您遇到了什么问题?
-
你有没有弄明白这件事?我有同样的问题,我不想包括该区域:在每次调用 Geocoder.search 时。
标签: ruby-on-rails ruby restriction country