Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

addTimeslider

Add Time Slider to Leaflet


Description

The LeafletSlider plugin enables you to dynamically add and remove Markers on a map by using a JQuery UI slider.

Usage

addTimeslider(map, data, options = timesliderOptions())

Arguments

map

a map widget

data

data must be a POINT Simple Feature with a time column.

options

List of additional options. See timesliderOptions

Value

the new map object

References

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)

leaflet.extras2

Extra Functionality for 'leaflet' Package

v1.1.0
GPL-3 | file LICENSE
Authors
Gatscha Sebastian [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.