| osrm_gui | R Documentation |
Launches a lightweight Shiny application to interactively visualize routing
on a local OSRM server. This interface mimics the r5rgui experience,
supporting left-click for start, right-click for end, and draggable markers.
osrm_gui(
input_osrm = NULL,
port = "auto",
style = "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",
center = NULL,
zoom = NULL,
autozoom = TRUE,
update_while_drag = FALSE,
debug = FALSE
)
input_osrm |
Optional. Can be:
|
port |
Integer or |
style |
Character. Map style for |
center |
Numeric vector of length 2 ( |
zoom |
Numeric. Initial zoom level. If |
autozoom |
Logical. Whether to enable auto-zoom by default. Defaults to |
update_while_drag |
Logical. Whether to enable live tracking mode by default (updates route while dragging). Defaults to |
debug |
Logical. Whether to enable debug mode (prints OSRM requests to console). Defaults to |
The function checks for optional dependencies shiny, mapgl, osrm, sf, and DT.
If missing, it prompts the user to install them.
It attempts to detect an active OSRM server. If an OSRM job process (from
osrm_start()) is passed, it uses that configuration. If a path is passed,
it will start a temporary server for the session.
No return value; launches a Shiny Gadget.
if (interactive()) {
# 1. Auto-detect running server (errors if none running):
osrm_gui()
# 2. Connect to specific port:
# osrm_gui(port = 5001)
# 3. Start from a graph file (auto-center on PBF):
# osrm_gui("berlin.osrm.mldgr")
# 4. Start from PBF with auto-center:
# osrm_gui("berlin.osm.pbf")
# 5. Explicit center and zoom:
# osrm_gui(port = 5001, center = c(13.4, 52.5), zoom = 12)
# 6. Use an existing process (must specify port):
# srv <- osrm_start("graph.osrm.mldgr", port = 6000)
# osrm_gui(srv, port = 6000)
# 7. Enable debug mode:
# osrm_gui(debug = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.