Sha256: 383d4fcd4f755b64e0d69583bb5b3510277ebea6eb63e624e8f98a9bf9188ae0

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

h2. Usage

Get a google maps API key, and store in your app under GOOGLE_MAPS_API_KEY
<pre>GOOGLE_MAPS_API_KEY = 'your_api_key'</pre>

<pre>directions = GoogleDirections.new(origin, destination)</pre>
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
<pre>
drive_time_in_minutes = directions.drive_time_in_minutes
distance_in_miles = directions.distance_in_miles
</pre>

Get the XML Google returns with every turn, or the API call URL
<pre>
xml = directions.xml  
xml_call = directions.xml_call
</pre>

h3. Error situations

If Google can't recognize your places, the distance_in_miles and drive_time_in_minutes will each return 0.  You can call <pre>directions.status</pre> and it should return "NOT_FOUND" (directions.status will also return any other Google API call statuses)

TODO: handle QUERY_OVER_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
# <pre>bundle install</pre> from command line

h3. Rails plugin

Rails 2.3
<pre>script/plugin install git://github.com/joshcrews/google-directions-ruby.git</pre>

Rails 3.0
<pre>rails plugin install git://github.com/joshcrews/google-directions-ruby.git</pre>

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)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
google_directions-0.1.1 README.textile