addMovingMarker | R Documentation |
The function expects either line or point data as spatial data or as Simple Feature. Alternatively, coordinates can also be passed as numeric vectors.
addMovingMarker(
map,
lng = NULL,
lat = NULL,
layerId = NULL,
group = NULL,
duration = 2000,
icon = NULL,
popup = NULL,
popupOptions = NULL,
label = NULL,
labelOptions = NULL,
movingOptions = movingMarkerOptions(),
options = leaflet::markerOptions(),
data = leaflet::getMapData(map)
)
map |
the map to add moving markers |
lng |
a numeric vector of longitudes, or a one-sided formula of the form
|
lat |
a vector of latitudes or a formula (similar to the |
layerId |
In order to be able to address the moving markings individually, a layerId is required. If none is specified, one is created that is derived from the current timestamp. |
group |
the name of the group the newly created layers should belong to
(for |
duration |
Duration in milliseconds per line segment between 2 points.
Can be a vector or a single number. Default is |
icon |
the icon(s) for markers; |
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 |
movingOptions |
a list of extra options for moving markers.
See |
options |
a list of extra options for markers. See
|
data |
the data object from which the argument values are derived; by
default, it is the |
the new map
object
https://github.com/ewoken/Leaflet.MovingMarker
Other MovingMarker Functions:
movingMarkerOptions()
,
startMoving()
library(sf)
library(leaflet)
library(leaflet.extras2)
crds <- data.frame(structure(
c(
-67.5, -68.5, -69.6, -70.5, -71.3, -72.2, -72.7,
-72.9, -73, -72.4, -70.8, 15.8, 16.5, 17.3, 17.8, 18.3, 18.6,
19.8, 21.6, 23.5, 25.1, 27.9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
),
dim = c(11L, 3L), dimnames = list(NULL, c("X", "Y", "L1"))
))
df <- st_sf(st_sfc(st_linestring(as.matrix(crds), dim = "XYZ"), crs = 4326))
st_geometry(df) <- "geometry"
df <- st_zm(df)
leaflet() %>%
addTiles() %>%
addPolylines(data = df) %>%
addMovingMarker(
data = df,
movingOptions = movingMarkerOptions(autostart = TRUE, loop = TRUE),
label = "I am a pirate!",
popup = "Arrr"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.