Sha256: a434db91a0e1badf57e594f38e95e96316585c663067798164296ad7b0dd439e
Contents?: true
Size: 1.01 KB
Versions: 4
Compression:
Stored size: 1.01 KB
Contents
require 'geocoder/lookups/base' require "geocoder/results/google" module Geocoder::Lookup class Google < Base private # --------------------------------------------------------------- def results(query, reverse = false) return [] unless doc = fetch_data(query, reverse) case doc['status']; when "OK" # OK status implies >0 results return doc['results'] when "OVER_QUERY_LIMIT" warn "Google Geocoding API error: over query limit." when "REQUEST_DENIED" warn "Google Geocoding API error: request denied." when "INVALID_REQUEST" warn "Google Geocoding API error: invalid request." end return [] end def query_url(query, reverse = false) params = { (reverse ? :latlng : :address) => query, :sensor => "false", :language => Geocoder::Configuration.language, :key => Geocoder::Configuration.api_key } "#{protocol}://maps.google.com/maps/api/geocode/json?" + hash_to_query(params) end end end
Version data entries
4 entries across 4 versions & 2 rubygems