
Product
Announcing Socket Certified Patches: One-Click Fixes for Vulnerable Dependencies
A safer, faster way to eliminate vulnerabilities without updating dependencies
mapbox_directions
Advanced tools
Ruby wrapper for the MapBox Directions Service.
Here you can find the documentation of the API interface: https://www.mapbox.com/developers/api/directions/
Add this line to your application's Gemfile:
gem 'mapbox_directions'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mapbox_directions
Here's the list of supported parameters and the possible values. Note that parameters that are not optional are required:
driving, cyclingorwalking."#{lng},#{lat}""#{lng},#{lat}"geojson(default), polylineand false to omit geometry.true(default) or false as a Boolean.text(default) or html.require "mapbox_directions"
parameters = {
access_token: "<your_access_token>",
mode: "driving", # %w(driving cycling walking)
origin: "-122.42,37.78", # "#{lng},#{lat}"
destination: "-77.03,38.91", # "#{lng},#{lat}"
geometry: "polyline", # %w(polyline geojson false)
alternatives: false, # true or false
instructions: "text", # %w(text html)
}
MapboxDirections.directions(parameters)
MapboxDirections.directions(parameters)
Will return a MapboxDirections::Response that will be composed by:
MapboxDirections::Location): Origin location of the route.MapboxDirections::Location): Destination location of the route.MapboxDirections::Route): Array of routes returned.MapboxDirections::Location:
MapboxDirections::Route:
Array[MapboxDirections::Step])1e6).
In order to get the polyline string transformed into another precision use this method passing the desired precision, which by default is 5 1e5.
To know more about how polyline are built from coordinates:
https://developers.google.com/maps/documentation/utilities/polylinealgorithmMapboxDirections::Step:
MapboxDirections::Maneuver)MapboxDirections::Maneuver:
For more information about what the values of these attributes contain, please look at the documentation.
Exceptions are triggered to give immediate feedback when there's something wrong in the parameters passed that won't allow to get a successful response.
MapboxDirections::MissingAccessTokenError: When the access token is not passed in the parameters or its value is nil
MapboxDirections::InvalidAccessTokenError: When the access token is passed in the parameters but it's invalid
MapboxDirections::CoordinatesFormatError: When the decimal coordinates are passed bad formatted given the requirements.
MapboxDirections::UnsupportedTransportModeError: When the mode of transport is different that the ones that the service supports.
If the exception raise is an undesired behaviour in the context where the code is being executed, they can be rescued one by one or all at once follows:
require "mapbox_directions"
def directions(parameters)
MapboxDirections.directions(parameters)
rescue MapboxDirections::Error
# Handle exception
end
git checkout -b my-new-feature)git commit -am 'Add some feature')git push origin my-new-feature)FAQs
Unknown package
We found that mapbox_directions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
A safer, faster way to eliminate vulnerabilities without updating dependencies

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.

Research
/Security News
Malicious npm packages use Adspect cloaking and fake CAPTCHAs to fingerprint visitors and redirect victims to crypto-themed scam sites.