The LeafletSlider plugin enables you to dynamically add and remove Markers/Lines on a map by using a JQuery UI slider.
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()
)
a map widget
data must be a Simple Feature collection of type POINT or LINESTRING with a column of class Date or POSIXct.
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
data
(units in meters for circles, and pixels for circle markers)
whether to draw stroke along the path (e.g. the borders of polygons or circles)
stroke color
stroke width in pixels
stroke opacity (or layer opacity for tile layers)
whether to fill the path with color (e.g. filling on polygons or circles)
fill color
fill opacity
a string that defines the stroke dash pattern
a character vector of the HTML content for the popups (you are
recommended to escape the text using htmlEscape()
for security reasons)
A Vector of popupOptions
to provide popups
a character vector of the HTML content for the labels
A Vector of labelOptions
to provide label
options for each label. Default NULL
boolean value indicating whether to order the data by the
time column. The slider will adopt the order of the timestamps.
The default is TRUE
.
List of additional options. See timesliderOptions
the new map
object
Other Timeslider Functions:
removeTimeslider()
,
timesliderOptions()
if (FALSE) {
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)
}