add_geolocate_control | R Documentation |
This function adds a Geolocate control to a Mapbox GL or MapLibre GL map. The geolocate control allows users to track their current location on the map.
add_geolocate_control(
map,
position = "top-right",
track_user = FALSE,
show_accuracy_circle = TRUE,
show_user_location = TRUE,
show_user_heading = FALSE,
fit_bounds_options = list(maxZoom = 15),
position_options = list(enableHighAccuracy = FALSE, timeout = 6000)
)
map |
A map object created by the |
position |
The position of the control. Can be one of "top-left", "top-right", "bottom-left", or "bottom-right". Default is "top-right". |
track_user |
Whether to actively track the user's location. If TRUE, the map will continuously update as the user moves. Default is FALSE. |
show_accuracy_circle |
Whether to show a circle indicating the accuracy of the location. Default is TRUE. |
show_user_location |
Whether to show a dot at the user's location. Default is TRUE. |
show_user_heading |
Whether to show an arrow indicating the device's heading when tracking location. Only works when track_user is TRUE. Default is FALSE. |
fit_bounds_options |
A list of options for fitting bounds when panning to the user's location. Default maxZoom is 15. |
position_options |
A list of Geolocation API position options. Default has enableHighAccuracy=FALSE and timeout=6000. |
The modified map object with the geolocate control added.
## Not run:
library(mapgl)
mapboxgl() |>
add_geolocate_control(
position = "top-right",
track_user = TRUE,
show_user_heading = TRUE
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.