Class: Graticule::Geocoder::Mapquest

Inherits:
Base
  • Object
show all
Defined in:
lib/graticule/geocoder/mapquest.rb

Overview

Mapquest uses the Licenced Community API which requires an api key. You can sign up an account and get an api key by registering at: developer.mapquest.com/

mq = Graticule.service(:mapquest).new(API_KEY) location = gg.locate(‘44 Allen Rd., Lovell, ME 04051’)

42.78942, -86.104424

Defined Under Namespace

Classes: Address, Locations, Request, Response, Result

Constant Summary

Constants inherited from Base

Base::USER_AGENT

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Mapquest

Returns a new instance of Mapquest.



14
15
16
17
# File 'lib/graticule/geocoder/mapquest.rb', line 14

def initialize(api_key)
  @api_key = api_key
  @url = URI.parse('http://www.mapquestapi.com/geocoding/v1/address')
end

Instance Method Details

#locate(address) ⇒ Object

Locates address returning a Location



20
21
22
# File 'lib/graticule/geocoder/mapquest.rb', line 20

def locate(address)
  get :q => address.is_a?(String) ? address : location_from_params(address).to_s
end