Geocoder gem是否可以与Google API密钥一起使用? [英] Does Geocoder gem work with google API key?

查看:85
本文介绍了Geocoder gem是否可以与Google API密钥一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的项目使用ruby geocoder gem,随着项目的发展,我开始考虑连接到Google API密钥.将其添加到项目后:

I am using ruby geocoder gem for my project and as the project is growing I am starting to look into connecting to the Google API key. After adding this to the project:

Geocoder.configure do |config|

# geocoding service (see below for supported options):
config.lookup = :google

# to use an API key:
config.api_key = 'my_key'

# geocoding service request timeout, in seconds (default 3):
config.timeout = 5

end 

我收到Google Geocoding API错误:请求被拒绝.当我启动应用程序时.从阅读中可以看出,如果其他人选择继续使用gem,他们似乎会切换到yahoo.我可以配置gem与Google api键一起使用吗?主要是,我想注意每日查询的数量,以免超出限制.

I get Google Geocoding API error: request denied. when I start the application. From reading around, it seems like others switch over to yahoo if they choose to continue using the gem. Can I configure the gem to work with google api key? Mainly, I would like to keep an eye out for the amount of daily queries to avoid going over the limit.

推荐答案

Geocoder仅支持Google Premier帐户的Google api密钥.

Geocoder supports Google api keys for Google Premier accounts only.

在github上的自述文件中找到了它: https://github.com/alexreisner/geocoder#google- google-google_premier

Its found here in the readme on github: https://github.com/alexreisner/geocoder#google-google-google_premier

如果您具有Google Premier api密钥,则只需将其放入初始化器中即可.

If you have a Google Premier api key you just need to put this in an intializer:

# config/initializers/geocoder.rb
   Geocoder.configure(:lookup => :google_premier, :api_key => "...")

您的Geocoder将使用您的主键.

And your Geocoder will use your premier key.

这篇关于Geocoder gem是否可以与Google API密钥一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆