Rails 地理编码器 gem & Google 自动完成 API - 已达到查询限制
Rails Geocoder gem & Google Autocomplete API - Query Limit Reached
我尝试实现 Google 的自动完成功能 API,当用户键入位置并按下输入时,带有标记的地图会加载到另一个页面中。它看起来和爱彼迎一模一样。搜索,然后映射..
我的问题是,最近我收到 "query size limit reached" 错误。我在这里阅读了所有关于这个问题的帖子,但找不到解决方案。
基本上,当用户输入字符串形式的地址时,我会得到该字符串并将其用于 google 地图的初始纬度和经度。我使用地理编码器 gem 和服务器作为 Heroku。
这是它的样子;
@search = params[:search]
if !@search.nil? && @search.strip != ""
location = Geocoder.search(params[:search])
@initlat = location[0].latitude
@initlng = location[0].longitude
end
为什么会出现此错误,我该如何解决?
https://developers.google.com/maps/documentation/geocoding/usage-limits
Users of the standard API:
2,500 free requests per day, calculated as the sum of client-side and server-side queries.
50 requests per second, calculated as the sum of client-side and server-side queries.
付费使用
Enable pay-as-you-go billing to unlock higher quotas:
[=11=].50 USD / 1000 additional requests, up to 100,000 daily.
ENABLE BILLING
只需单击 启用计费 按钮并获取 API 密钥并设置 geocoder.rb
# config/initializers/geocoder.rb
Geocoder.configure(
# geocoding service (see below for supported options):
:lookup => :yandex,
# IP address geocoding service (see below for supported options):
:ip_lookup => :maxmind,
# to use an API key:
:api_key => "...",
# geocoding service request timeout, in seconds (default 3):
:timeout => 5,
# set default units to kilometers:
:units => :km,
# caching (see below for details):
:cache => Redis.new,
:cache_prefix => "..."
)
我尝试实现 Google 的自动完成功能 API,当用户键入位置并按下输入时,带有标记的地图会加载到另一个页面中。它看起来和爱彼迎一模一样。搜索,然后映射..
我的问题是,最近我收到 "query size limit reached" 错误。我在这里阅读了所有关于这个问题的帖子,但找不到解决方案。
基本上,当用户输入字符串形式的地址时,我会得到该字符串并将其用于 google 地图的初始纬度和经度。我使用地理编码器 gem 和服务器作为 Heroku。
这是它的样子;
@search = params[:search]
if !@search.nil? && @search.strip != ""
location = Geocoder.search(params[:search])
@initlat = location[0].latitude
@initlng = location[0].longitude
end
为什么会出现此错误,我该如何解决?
https://developers.google.com/maps/documentation/geocoding/usage-limits
Users of the standard API:
2,500 free requests per day, calculated as the sum of client-side and server-side queries.
50 requests per second, calculated as the sum of client-side and server-side queries.
付费使用
Enable pay-as-you-go billing to unlock higher quotas:
[=11=].50 USD / 1000 additional requests, up to 100,000 daily.
ENABLE BILLING
只需单击 启用计费 按钮并获取 API 密钥并设置 geocoder.rb
# config/initializers/geocoder.rb
Geocoder.configure(
# geocoding service (see below for supported options):
:lookup => :yandex,
# IP address geocoding service (see below for supported options):
:ip_lookup => :maxmind,
# to use an API key:
:api_key => "...",
# geocoding service request timeout, in seconds (default 3):
:timeout => 5,
# set default units to kilometers:
:units => :km,
# caching (see below for details):
:cache => Redis.new,
:cache_prefix => "..."
)