Simmo
Simmo

Reputation: 1729

How do I setup geocoder with google_premier?

I've read the docs for the geocoder gem which state you can set a key, client and channel when using Google Premier.

According to some other posts I've read here, it's now possible to use an API key and still not pay as long as you're below the free threshold. We need to do this as we host with Heroku and we keep hitting our daily limit. We're not ourselves, but without any sort of other identification, we're probably reaching a limit identified by IP shared with other Heroku sites. Using a key will help identify us and therefore keep us from hitting a limit.

However, when I look at the sign up pages for the Google API, there are a baffling array of client ids, api keys and secrets, for installed apps, web apps and so on. Which combination is the one required to make geocoder burst into life?

Upvotes: 5

Views: 1840

Answers (2)

chopper
chopper

Reputation: 6709

This worked for me:

Geocoder.configure(
  :lookup => :google_premier,
  :api_key => [ 'GOOGLE_CRYPTO_KEY', 'GOOGLE_CLIENT_ID', 'GOOGLE_CHANNEL' ],
  :timeout => 5,
  :units => :km,
)

You'll need to substitute in the corresponding values from your Google Maps for Business welcome email. Channel is a value of your choosing.

Upvotes: 3

tal
tal

Reputation: 3433

To answer the question :

When subscribing to Google Premier, you should have received a client id starting by gme- and a key (see https://developers.google.com/maps/documentation/business/articles/prelaunch_checklist#welcome_letter)

The third argument needed by geocoder is the channel, that can be any kind of string (see https://developers.google.com/maps/documentation/business/guide#Channels )

You need to add the list of authorised urls originating the requests in the Google Portal (see https://developers.google.com/maps/documentation/business/guide#URLs ).

From the Geocoder doc, you can use a setting like :

# -*- encoding : utf-8 -*-
Geocoder.configure do |config|
  config.lookup = :google_premier
  config.api_key = ["gme-client-id","key", "channel"]
  config.timeout = 10
  config.units = :km
end

But it would probably be a better choice to use client-side geocoding like recommended here : https://developers.google.com/maps/articles/geocodestrat?hl=fr#client

Upvotes: 9

Related Questions