Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google_directions

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google_directions

  • 0.1.6.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

h2. Usage

directions = GoogleDirections.new(origin, destination)

where origin and destination are strings of addresses or places that Google can find an address for. Example: "816 Meridian St., 37207"

Get drive time or distance of whole trip

drive_time_in_minutes = directions.drive_time_in_minutes
distance_in_miles = directions.distance_in_miles

Get the XML Google returns with every turn, or the API call URL

xml = directions.xml  
xml_call = directions.xml_call

h3. Error situations

status: NOT_FOUND

If Google can't recognize your places, the distance_in_miles and drive_time_in_minutes will each return 0. You can call

directions.status
and it should return "NOT_FOUND" (directions.status will also return any other Google API call statuses)

status: OVER_QUERY_LIMIT

If Google thinks you've hit their API too many times in day, or too rapidly, for your given IP address and API key; they might return OVER_QUERY_LIMIT. In this case distance_in_miles and drive_time_in_minutes will each return 0. You can call

directions.status
and it should return "OVER_QUERY_LIMIT"

h2. Installation

h3. gem

rails 2.3

gem install google_directions

add config.gem "google_directions" to your environment.rb file

rails 3.0

gem 'google_directions' in your Gemfile

bundle install
from command line

h3. Rails plugin

Rails 2.3

script/plugin install git://github.com/joshcrews/google-directions-ruby.git

Rails 3.0

rails plugin install git://github.com/joshcrews/google-directions-ruby.git

h3. Compatibility

Tested on Rails 2.3.8

Not yet tested on Rails 3. It probably is Rails 3 compatible, because it's just a single class with a few methods. It's probably compatible with every ruby project ever.

h3. Google maps API key

You'll need a Google Map API key

http://code.google.com/apis/maps/signup.html

Include it as the constant GOOGLE_MAPS_API_KEY in an app configuration file (environment.rb, config/initializers/api_keys.rb)

h3. Need turn-by-turn directions?

Not yet included in this gem, but you can do it with nokogiri to parse the XML that comes back when you do

GoogleDirections.new(origin, destination).xml

And then nokogiri can cycle through each and you can pick out what you need.

h2. License

Anyone can use this code in any way.

FAQs

Package last updated on 26 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc