Socket
Book a DemoInstallSign in
Socket

google_map_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_map_directions

1.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Google Map Directions

A wrapper gem for the google directions API. https://developers.google.com/maps/documentation/directions/

Installation

Add this line to your application's Gemfile:

gem 'google_map_directions'

And then execute:

$ bundle

Or install it yourself as:

$ gem install google_map_directions

Usage

Currently, this gem only pulls a single route from the google directions api. The ability to search through multiple routes will be added at a later date.

Setup:

  directions = GoogleMapDirections::Directions.new('Soda Hall Berkeley CA', 'Foothill Berkeley CA')

You can check the status code to see if the request to the API was sucessful.

  directions.status

If you want to parse the data yourself, you can grab the ruby representation of the JSON object

  directions.json

There is a lot of basic information you can just get from the Directions object

  directions.distance_as_string
  directions.distance_in_meters

  directions.destination_coordinates
  directions.origin_coordinates   

  #The two coordinates methods return hashes that contain the latitude and longitude
  directions.destination_coordinates["lat"]
  directions.destination_coordinates["lng"]  


  directions.origin_address
  directions.destination_address
  directions.duration_as_string
  directions.duration_in_seconds

The steps of the route can be pulled from the step method

  directions.path_length
  #Returns the number of steps in the routes
  step1 = directions.step(0)
  #Returns the first step of the path  
  
  step1.distance_as_string
  step1.distance_in_meters
  step1.duration_as_string
  step1.duration_in_seconds


  step1.end_location
  step1.start_location

  #The two coordinates methods return hashes that contain the latitude and longitude
  step1.end_location["lat"]
  step1.end_location["lng"]  

  step1.number
  step1.HTML_instructions

Let me know of any bugs/additional features wanted.

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 08 Jan 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.