lib/geocoder/lookups/mapquest.rb in geocoder-1.1.5 vs lib/geocoder/lookups/mapquest.rb in geocoder-1.1.6
- old
+ new
@@ -3,29 +3,36 @@
require "geocoder/results/mapquest"
module Geocoder::Lookup
class Mapquest < Base
- private # ---------------------------------------------------------------
+ def name
+ "Mapquest"
+ end
+ def required_api_key_parts
+ ["key"]
+ end
+
def query_url(query)
- key = Geocoder::Configuration.api_key
+ key = configuration.api_key
domain = key ? "www" : "open"
url = "#{protocol}://#{domain}.mapquestapi.com/geocoding/v1/#{search_type(query)}?"
url + url_query_string(query)
end
+ private # ---------------------------------------------------------------
+
def search_type(query)
query.reverse_geocode? ? "reverse" : "address"
end
def query_url_params(query)
- key = Geocoder::Configuration.api_key
params = { :location => query.sanitized_text }
- if key
+ if key = configuration.api_key
params[:key] = CGI.unescape(key)
end
- super.merge(params)
+ params.merge(super)
end
def results(query)
return [] unless doc = fetch_data(query)
doc["results"][0]['locations']