How does the Rails Geocoder Gem access the Google APIs?

I know that we need to use a unique API key to access the Google Geocoding API. I use the Rails Geocoder Gem in my application and find out that it uses the Google Geocoding API. I could not find the configuration files that define the API keys for accessing the Google APIs. How GeomeDome Gem Access Google APIs.

+4
source share
1 answer
Geocoder.configure(
  :lookup => :google_premier,
  :api_key => [ 'GOOGLE_CRYPTO_KEY', 'GOOGLE_CLIENT_ID', 'GOOGLE_CHANNEL' ],
  :timeout => 5,
  :units => :km,
)

https://github.com/alexreisner/geocoder

Here is another link: http://hankstoever.com/posts/11-Pro-Tips-for-Using-Geocoder-with-Rails

Under Some general configuration options:

: Geocoder gem Google API?

:

Google api Google Premier.

Client-Side , ,

https://developers.google.com/maps/articles/geocodestrat

- , :

require 'net/http'
require "resolv-replace.rb"
require 'json'

url = URI("https://maps.googleapis.com/maps/api/geocode/json")
puts "enter country code"
c_code = gets
puts "enter zip code "
zip = gets

url.query= URI.encode_www_form({ address: "#{c_code.chomp}+#{zip.chomp}" })
res = Net::HTTP::get_response(url)

json_data = res.body if res.is_a?(Net::HTTPSuccess)

data = JSON.parse(json_data)
p data
+3

All Articles