Skip to content
Snippets Groups Projects
Commit d4c40aee authored by Alex Reisner's avatar Alex Reisner
Browse files

Merge pull request #486 from robdiciuccio/mapquest

API key required for MapQuest Open services.

As of 15 July 2013. See: http://developer.mapquest.com/web/products/open/forums/-/message_boards/view_message/459709
parents bb2d338a d521c841
No related branches found
No related tags found
No related merge requests found
...@@ -374,7 +374,7 @@ Yahoo BOSS is **not a free service**. As of November 17, 2012 Yahoo no longer of ...@@ -374,7 +374,7 @@ Yahoo BOSS is **not a free service**. As of November 17, 2012 Yahoo no longer of
#### Mapquest (`:mapquest`) #### Mapquest (`:mapquest`)
* **API key**: required for the licensed API, do not use for open tier * **API key**: required
* **Quota**: ? * **Quota**: ?
* **HTTP Headers**: in order to use the licensed API you can configure the http_headers to include a referer as so: * **HTTP Headers**: in order to use the licensed API you can configure the http_headers to include a referer as so:
`Geocoder.configure(:http_headers => { "Referer" => "http://foo.com" })` `Geocoder.configure(:http_headers => { "Referer" => "http://foo.com" })`
...@@ -385,6 +385,7 @@ Yahoo BOSS is **not a free service**. As of November 17, 2012 Yahoo no longer of ...@@ -385,6 +385,7 @@ Yahoo BOSS is **not a free service**. As of November 17, 2012 Yahoo no longer of
* **Documentation**: http://www.mapquestapi.com/geocoding/ * **Documentation**: http://www.mapquestapi.com/geocoding/
* **Terms of Service**: http://info.mapquest.com/terms-of-use/ * **Terms of Service**: http://info.mapquest.com/terms-of-use/
* **Limitations**: ? * **Limitations**: ?
* **Notes**: You can specify the licensed API by setting: `Geocoder.configure(:mapquest => {:licensed => true})` (defaults to free "open" version)
#### Ovi/Nokia (`:ovi`) #### Ovi/Nokia (`:ovi`)
......
...@@ -10,12 +10,11 @@ module Geocoder::Lookup ...@@ -10,12 +10,11 @@ module Geocoder::Lookup
end end
def required_api_key_parts def required_api_key_parts
[] ["key"]
end end
def query_url(query) def query_url(query)
key = configuration.api_key domain = configuration[:licensed] ? "www" : "open"
domain = key ? "www" : "open"
url = "#{protocol}://#{domain}.mapquestapi.com/geocoding/v1/#{search_type(query)}?" url = "#{protocol}://#{domain}.mapquestapi.com/geocoding/v1/#{search_type(query)}?"
url + url_query_string(query) url + url_query_string(query)
end end
......
...@@ -276,6 +276,15 @@ class ServicesTest < Test::Unit::TestCase ...@@ -276,6 +276,15 @@ class ServicesTest < Test::Unit::TestCase
lookup = Geocoder::Lookup::Mapquest.new lookup = Geocoder::Lookup::Mapquest.new
query = Geocoder::Query.new("Bluffton, SC") query = Geocoder::Query.new("Bluffton, SC")
res = lookup.query_url(query) res = lookup.query_url(query)
assert_equal "http://open.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton%2C+SC",
res
end
def test_api_route_licensed
Geocoder.configure(:lookup => :mapquest, :api_key => "abc123", :mapquest => {:licensed => true})
lookup = Geocoder::Lookup::Mapquest.new
query = Geocoder::Query.new("Bluffton, SC")
res = lookup.query_url(query)
assert_equal "http://www.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton%2C+SC", assert_equal "http://www.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton%2C+SC",
res res
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment