Description Usage Arguments Value See Also Examples
This function takes source and target data, together with options for the API and drawing options, and returns the map with the requested routes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | getTargomoRoutes(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)
drawTargomoRoutes(map, routes, drawOptions = routeDrawOptions(),
group = NULL, ...)
addTargomoRoutes(map, source_data = NULL, source_lat = NULL,
source_lng = NULL, source_id = NULL, target_data = NULL,
target_lat = NULL, target_lng = NULL, target_id = NULL,
options = targomoOptions(), drawOptions = routeDrawOptions(),
group = NULL, api_key = Sys.getenv("TARGOMO_API_KEY"),
region = Sys.getenv("TARGOMO_REGION"), config = list(),
verbose = FALSE, progress = FALSE, timeout = NULL)
|
source_data, target_data |
The source and target points for your routes - supported types are data.frame matrix and objects from the sf and sp packages. |
source_lat, source_lng |
Columns identifying the latitude and longitude columns in your sourcedata, or numeric vectors of equal length. |
target_lat, target_lng |
As for |
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 |
api_key |
Your Targomo API key - defaults to the |
region |
Your Targomo region - defaults to the |
config |
Config options to pass to |
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 |
routes |
A list of route segments provided by |
drawOptions |
A list of |
group |
The leaflet map group to add the routes to. One group is used for all map elements being drawn per call to the API. |
... |
Further arguments to pass to |
For 'get*', a list of objects of class "sf" containing the routes For 'draw*' and 'add*', the leaflet map returned with the routes drawn on.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # load leaflet package
library(leaflet)
l <- leaflet()
# get route from Big Ben to Tower Bridge
r <- getTargomoRoutes(source_lat = 51.5007, source_lng = -0.1246,
target_lat = 51.5055, target_lng = -0.0754,
options = targomoOptions(travelType = c("bike", "transit")))
# draw the routes on the map
l %>% drawTargomoRoutes(routes = r)
# note, could combine get.. and draw... into one with add...
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.