lib/geokit/geocoders/google.rb in geokit-1.8.4 vs lib/geokit/geocoders/google.rb in geokit-1.8.5

- old
+ new

@@ -1,9 +1,10 @@ module Geokit module Geocoders class GoogleGeocoder < Geocoder - config :client_id, :cryptographic_key, :channel + config :client_id, :cryptographic_key, :channel, :api_key + self.secure = true private # ==== OPTIONS # * :language - See: https://developers.google.com/maps/documentation/geocoding def self.do_reverse_geocode(latlng, options = {}) @@ -60,12 +61,15 @@ query_string = "/maps/api/geocode/json?sensor=false&#{query_string}#{language_str}" if client_id && cryptographic_key channel_string = channel ? "&channel=#{channel}" : '' urlToSign = query_string + "&client=#{client_id}" + channel_string signature = sign_gmap_bus_api_url(urlToSign, cryptographic_key) - "http://maps.googleapis.com" + urlToSign + "&signature=#{signature}" + "#{protocol}://maps.googleapis.com" + urlToSign + "&signature=#{signature}" + elsif api_key + url_with_key = query_string + "&key=#{api_key}" + "#{protocol}://maps.googleapis.com" + url_with_key else - "http://maps.google.com" + query_string + "#{protocol}://maps.google.com" + query_string end end def self.construct_bias_string_from_options(bias)