Learn R Programming

azuremapsr (version 0.0.2)

req_route_directions: Get Route Directions from 'Azure Maps'

Description

Requests route directions from 'Azure Maps' API using origin, destination, waypoints, and route parameters.

Usage

req_route_directions(
  origin,
  destination,
  waypoints = NULL,
  params,
  tz = Sys.timezone(),
  api_key = get_azuremaps_token(),
  api_version = "2025-01-01"
)

Value

An httr2_response object from the 'Azure Maps' API.

Arguments

origin

A numeric vector of length 2 with origin coordinates (longitude, latitude), or an sf object with a single POINT geometry.

destination

A numeric vector of length 2 with destination coordinates (longitude, latitude), or an sf object with a single POINT geometry.

waypoints

Optional. A numeric vector, a matrix of coordinates, or an sf object with POINT geometries representing intermediate stops.

params

A list of route parameters (e.g., optimizeRoute, routeOutputOptions, maxRouteCount, travelMode). See the API documentation

tz

A string specifying the timezone. Defaults to the system's timezone.

api_key

The 'Azure Maps' API key. Defaults to the value retrieved by get_azuremaps_token().

api_version

The API version to use. Defaults to "2025-01-01".

Examples

Run this code
if (FALSE) {
origin <- c(-122.201399, 47.608678)
destination <- c(-122.201669, 47.615076)
waypoints <- c(-122.20687, 47.612002)

params <- list(
  optimizeRoute = "fastestWithTraffic",
  routeOutputOptions = "routePath",
  maxRouteCount = 3,
  travelMode = "driving"
)

response <- req_route_directions(origin, destination, waypoints, params)
}

Run the code above in your browser using DataLab