mb_directions {mapboxapi} | R Documentation |
Make a request to the Mapbox Directions API
Description
See the Mapbox Directions API documentation for more information.
Usage
mb_directions(
input_data = NULL,
origin = NULL,
destination = NULL,
profile = "driving",
output = "sf",
depart_at = NULL,
alternatives = NULL,
annotations = NULL,
bearings = NULL,
continue_straight = NULL,
exclude = NULL,
geometries = "geojson",
overview = "simplified",
radiuses = NULL,
approaches = NULL,
steps = NULL,
banner_instructions = NULL,
language = NULL,
roundabout_exits = NULL,
voice_instructions = NULL,
voice_units = NULL,
waypoint_names = NULL,
waypoint_targets = NULL,
waypoints = NULL,
walking_speed = NULL,
walkway_bias = NULL,
alley_bias = NULL,
access_token = NULL
)
Arguments
input_data |
An input dataset of class |
origin |
An address or coordinate pair that represents the origin of
your requested route. Cannot be used with |
destination |
An address or coordinate pair that represents the destination of your requested route. |
profile |
One of "driving" (the default), "driving-traffic", "walking", or "cycling". |
output |
One of "sf" (the default), which returns an sf LINESTRING representing the route geometry, or "full", which returns the full request from the Directions API as a list. |
depart_at |
(optional) For the "driving" or "driving-traffic" profiles,
the departure date and time to reflect historical traffic patterns. If
"driving-traffic" is used, live traffic will be mixed in with historical
traffic for dates/times near to the current time. Should be specified as an
ISO 8601 date/time, e.g. |
alternatives |
Whether or not to return alternative routes with your request. If TRUE, a list of up to 3 possible routes will be returned. |
annotations |
A comma-separated string of additional route metadata, which may include duration, distance, speed, and congestion. Must be used with overview = "full". |
bearings |
A semicolon-delimited character string of bearings |
continue_straight |
continue_straight |
exclude |
Road types to exclude from your route; possible choices are
|
geometries |
The route geometry format. If |
overview |
If left blank, defaults to |
radiuses |
A character string with semicolon-separated radii that
specify the distance (in meters) to snap each input coordinate to the road
network. Defaults to |
approaches |
A character string with semicolon-separated specifications
for how to approach waypoints. Options include |
steps |
If |
banner_instructions |
Whether or not to return banner objects; only
available when |
language |
The language of the returned instructions (defaults to
English). Available language codes are found at
https://docs.mapbox.com/api/navigation/#instructions-languages. Only
available when |
roundabout_exits |
If TRUE, adds instructions for roundabout entrance
and exit. Only available when |
voice_instructions , voice_units |
Only available when |
waypoint_names , waypoint_targets , waypoints |
Only available when |
walking_speed |
The walking speed in meters/second; available when
|
walkway_bias |
Can take values between -1 and 1, where negative numbers
avoid walkways and positive numbers prefer walkways. Available when
|
alley_bias |
Can take values between -1 and 1, where negative numbers
avoid alleys and positive numbers prefer alleys. Available when |
access_token |
A Mapbox access token; which can be set with
|
Value
An sf
object (or list of sf
objects), or full R list representing
the API response.
Examples
## Not run:
library(mapboxapi)
library(leaflet)
my_route <- mb_directions(
origin = "10 Avenue de Wagram, 75008 Paris France",
destination = "59 Rue de Tocqueville, 75017 Paris France",
profile = "cycling",
steps = TRUE,
language = "fr"
)
leaflet(my_route) %>%
addMapboxTiles(
style_id = "light-v9",
username = "mapbox"
) %>%
addPolylines()
## End(Not run)