Class: Graticule::Geocoder::Mapquest

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

Overview

Mapquest requires both a client id and a password, which you can get by registering at: developer.mapquest.com/Home/Register?_devAPISignup_WAR_devAPISignup_action=signup&_devAPISignup_WAR_devAPISignup_clientType=Developer

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

42.78942, -86.104424

Defined Under Namespace

Classes: Address, Result

Constant Summary collapse

PRECISION =

I would link to the documentation here, but there is none that will do anything but confuse you.

{
  'L1' => Precision::Address,
  'I1' => Precision::Street,
  'B1' => Precision::Street,
  'B2' => Precision::Street,
  'B3' => Precision::Street,
  'Z3' => Precision::PostalCode,
  'Z4' => Precision::PostalCode,
  'Z2' => Precision::PostalCode,
  'Z1' => Precision::PostalCode,
  'A5' => Precision::Locality,
  'A4' => Precision::Region,
  'A3' => Precision::Region,
  'A1' => Precision::Country
}

Constants inherited from Base

Base::USER_AGENT

Instance Method Summary collapse

Constructor Details

#initialize(client_id, password) ⇒ Mapquest

Returns a new instance of Mapquest.



31
32
33
34
35
# File 'lib/graticule/geocoder/mapquest.rb', line 31

def initialize(client_id, password)
  @password = password
  @client_id = client_id
  @url = URI.parse('http://geocode.dev.mapquest.com/mq/mqserver.dll')
end

Instance Method Details

#locate(address) ⇒ Object

Locates address returning a Location



38
39
40
# File 'lib/graticule/geocoder/mapquest.rb', line 38

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