Add Playback to Leaflet
The LeafletPlayback plugin provides the ability to replay GPS Points in the form of POINT Simple Features. Rather than simply animating a marker along a polyline, the speed of the animation is synchronized to a clock. The playback functionality is similar to a video player; you can start and stop playback or change the playback speed.
addPlayback( map, data, time = "time", icon = NULL, pathOpts = pathOptions(), options = playbackOptions() )
map |
a map widget |
data |
data must be a POINT Simple Feature or a list of POINT Simple Feature's with a time column. |
time |
The column name of the time column. Default is |
icon |
an icon which can be created with |
pathOpts |
style the CircleMarkers with
|
options |
List of additional options. See |
the new map
object
If used in Shiny, you can listen to 2 events
'map-ID'+"_pb_mouseover"
'map-ID'+"_pb_click"
Other Playback Functions:
playbackOptions()
,
removePlayback()
## Not run: library(leaflet) library(leaflet.extras2) library(sf) ## Single Elements 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() %>% addPlayback(data = data, options = playbackOptions(radius = 3), pathOpts = pathOptions(weight = 5)) ## Multiple Elements data <- sf::st_as_sf(leaflet::atlStorms2005[1:5,]) data$Name <- as.character(data$Name) data <- st_cast(data, "POINT") data <- split(data, f = data$Name) lapply(1:length(data), function(x) { data[[x]]$time <<- as.POSIXct( seq.POSIXt(Sys.time() - 1000, Sys.time(), length.out = nrow(data[[x]]))) }) leaflet() %>% addTiles() %>% addPlayback(data = data, options = playbackOptions(radius = 3, color = c("red","green","blue", "orange","yellow")), pathOpts = pathOptions(weight = 5)) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.