addTimeslider {leaflet.extras2} | R Documentation |
Add Time Slider to Leaflet
Description
The LeafletSlider plugin enables you to dynamically add and remove Markers/Lines on a map by using a JQuery UI slider.
Usage
addTimeslider(
map,
data,
radius = 10,
stroke = TRUE,
color = "#03F",
weight = 5,
opacity = 0.5,
fill = TRUE,
fillColor = color,
fillOpacity = 0.2,
dashArray = NULL,
popup = NULL,
popupOptions = NULL,
label = NULL,
labelOptions = NULL,
ordertime = TRUE,
options = timesliderOptions()
)
Arguments
map |
a map widget |
data |
data must be a Simple Feature collection of type POINT or LINESTRING with a column of class Date or POSIXct. |
radius |
a numeric vector of radii for the circles; it can also be a
one-sided formula, in which case the radius values are derived from the
|
stroke |
whether to draw stroke along the path (e.g. the borders of polygons or circles) |
color |
stroke color |
weight |
stroke width in pixels |
opacity |
stroke opacity (or layer opacity for tile layers) |
fill |
whether to fill the path with color (e.g. filling on polygons or circles) |
fillColor |
fill color |
fillOpacity |
fill opacity |
dashArray |
a string that defines the stroke dash pattern |
popup |
a character vector of the HTML content for the popups (you are
recommended to escape the text using |
popupOptions |
A Vector of |
label |
a character vector of the HTML content for the labels |
labelOptions |
A Vector of |
ordertime |
boolean value indicating whether to order the data by the
time column. The slider will adopt the order of the timestamps.
The default is |
options |
List of additional options. See |
Value
the new map
object
References
https://github.com/dwilhelm89/LeafletSlider
See Also
Other Timeslider Functions:
removeTimeslider()
,
timesliderOptions()
Examples
## Not run:
library(leaflet)
library(leaflet.extras2)
library(sf)
library(geojsonsf)
data <- sf::st_as_sf(leaflet::atlStorms2005[1,])
data <- st_cast(data, "POINT")
data$time = as.POSIXct(
seq.POSIXt(Sys.time() - 1000, Sys.time(), length.out = nrow(data)))
leaflet() %>%
addTiles() %>%
addTimeslider(data = data,
options = timesliderOptions(
position = "topright",
timeAttribute = "time",
range = TRUE)) %>%
setView(-72, 22, 4)
## End(Not run)