Skip to content

Latest commit

 

History

History
38 lines (33 loc) · 1.19 KB

matrix.md

File metadata and controls

38 lines (33 loc) · 1.19 KB

Matrix

require "mapbox-sdk"
Mapbox.access_token = "YOUR_ACCESS_TOKEN"

# Return travel times between many points, passing in the required profile parameter.
matrix = Mapbox::Matrix.matrix([{
  "longitude" => -122.42,
  "latitude" => 37.78
}, {
  "longitude" => -122.45,
  "latitude" => 37.91
}, {
 "longitude" => -122.48,
  "latitude" => 37.73
  }], "walking")

# To provide query parameters to the Matrix API, such as `annotations`, `approaches` or `sources`, add those in a Hash as third parameter (find the full list of parameters (here)[https://www.mapbox.com/api-documentation/navigation/#matrix]).

# For instance, to use the `annotations`, `approaches`, and `destinations` parameters:
matrix = Mapbox::Matrix.matrix([{
  "longitude" => -122.42,
  "latitude" => 37.78
}, {
  "longitude" => -122.45,
  "latitude" => 37.91
}, {
 "longitude" => -122.48,
  "latitude" => 37.73
  }], "cycling", {
    annotations: ["duration", "distance"],
    approaches: ["curb","","curb"],
    destinations: [0,1]
  })

# In the above example, you can substitute `driving` for `driving-traffic`, `cycling` or `walking`. For more, [check out the documentation](https://www.mapbox.com/api-documentation/navigation/#matrix).