This function takes source and target data, together with options for the API and drawing options, and returns the map with the requested travel time data.

getTargomoTimes(
  source_data = NULL,
  source_lat = NULL,
  source_lng = NULL,
  target_data = NULL,
  target_lat = NULL,
  target_lng = NULL,
  source_id = NULL,
  target_id = NULL,
  options = targomoOptions(),
  api_key = Sys.getenv("TARGOMO_API_KEY"),
  region = Sys.getenv("TARGOMO_REGION"),
  config = list(),
  verbose = FALSE,
  progress = FALSE,
  timeout = NULL
)

drawTargomoTimes(
  map,
  times,
  drawOptions = timeDrawOptions(),
  group = NULL,
  ...
)

addTargomoTimes(
  map,
  source_data = NULL,
  source_lat = NULL,
  source_lng = NULL,
  target_data = NULL,
  target_lat = NULL,
  target_lng = NULL,
  source_id = NULL,
  target_id = NULL,
  options = targomoOptions(),
  drawOptions = timeDrawOptions(),
  group = NULL,
  ...,
  api_key = Sys.getenv("TARGOMO_API_KEY"),
  region = Sys.getenv("TARGOMO_REGION"),
  config = list(),
  verbose = FALSE,
  progress = FALSE,
  timeout = NULL
)

Arguments

source_data, target_data

The source and target points for your travel times - supported types are data.frame matrix and objects from the sf and sp packages.

source_lat, source_lng

One-sided formulas identifying the latitude and longitude columns in your source data, or numeric vectors of equal length.

target_lat, target_lng

As for source_lat,source_lng but for target data.

source_id, target_id

Formulas or vectors of IDs to give to your source and target points. These will be used to match back to the input data if applicable.

options

A list of targomoOptions to send to the API.

api_key

Your Targomo API key - defaults to the TARGOMO_API_KEY ennvironment variable.

region

Your Targomo region - defaults to the TARGOMO_REGION environment variable.

config

Config options to pass to httr::POST e.g. proxy settings

verbose

Whether to print out information about the API call.

progress

Whether to show a progress bar of the API call.

timeout

Timeout in seconds (leave NULL for no timeout/curl default).

map

A leaflet map

times

A times dataset returned by getTargomoTimes

drawOptions

A list of timeDrawOptions to determine how to show the resulting times on the map.

group

The leaflet map group to add the times to. One group is used for all map elements being drawn per call to the API.

...

Further arguments to pass to addCircleMarkers

Value

For `get*`, an object of class "sf" containing the times. For `draw*` and `add*`, the leaflet map returned with the times drawn on as circle markers.

Examples

# \donttest{ # load leaflet package library(leaflet) l <- leaflet() # create a source point (Big Ben) and some random targets s <- data.frame(lat = 51.5007, lng = -0.1246, id = "BigBen") t <- data.frame(lat = runif(min = 51.495, max = 51.5055, n = 100), lng = runif(min = -0.175, max = -0.075, n = 100)) # get the times times <- getTargomoTimes(source_data = s, target_data = t, options = targomoOptions(travelType = "car"))
#> Assuming "lng" and "lat" are longitude and latitude, respectively
# draw them on the map l %>% drawTargomoTimes(times = times) # }