Project

mqproxy

0.0
No commit activity in last 3 years
No release in over 3 years
A wrapper for the MapQuest API, provides ability to get route and to geocode an address
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 0
 Project Readme

MQProxy¶ ↑

Connect to Map Quest’s API to:

  • geocode address

  • get route from one address to another

Installation¶ ↑

gem¶ ↑

gem install mqproxy

Plugin¶ ↑

Rails <= 2.3.8 ./script/plugin install git://github.com/cbrady/MQ-Proxy.git

Rails >= 3.0 rails plugin install git://github.com/cbrady/MQ-Proxy.git

Example¶ ↑

Set up the addresses:¶ ↑

Addresses can be setup in a Hash: address1 = {:postalCode => “<zip1>”, :street => “<street1>”, :adminArea1 => “<country1>”, :adminArea3 => “<state1>”, :adminArea4 => “<county1>”,:adminArea5 => “<city1>”} address2 = {:postalCode => “<zip2>”, :street => “<street2>”, :adminArea1 => “<country2>”, :adminArea3 => “<state2>”, :adminArea4 => “<county2>”,:adminArea5 => “<city2>”}

Or as strings: address1 = “<street1> <city1>, <state1> <zip1>” address2 = “<street2> <city2>, <state2> <zip2>”

To get route:¶ ↑

proxy = MQProxy.new route = proxy.get_route(address1, address2)

This returns a MQProxyRoute object

MQProxyRoute gives you access to certain attributes from the MapQuest response: time - total estimated travel time (seconds) distance - total distance of trip (default: miles - can be overwritten in options sent to MapQuest) directions - array of all steps of the trip raw - Hash containing entire response from MapQuest

To get geocode:¶ ↑

proxy = MQProxy.new code = proxy.geocode_address(address1)

This returns a MQProxyGeocode object

MQProxyGeocode gives you access to certain attributes from the MapQuest response: street - address’ street city - address’ city zip - address’ zip code county - address’ county state - address’ state country - address’ country lat - address’ latitude lgn - address’ longitude raw - Hash containing entire response from MapQuest

Options: ¶ ↑

To overwrite default MapQuest options pass mq_options Hash to method

proxy = MQProxy.new route = MQProxy.get_route(address1, address2, :mq_proxy => {:unit => ‘k’, :routeType => ‘shortest’})

The this tells MapQuest that you would like the shortest route possible and all of the distances in the response to be in kilometers instead of miles.

For a full list of options see the MapQuest API documentation:

www.mapquestapi.com/

Copyright © 2011 Christopher Brady, released under the MIT license