The Line Layer renders raised lines joining pairs of source and target coordinates

add_animated_line(
map,
data = get_map_data(map),
layer_id = NULL,
origin,
destination,
id = NULL,
stroke_colour = NULL,
stroke_width = NULL,
stroke_opacity = NULL,
frequency = 1,
animation_speed = 3,
trail_length = 5,
tooltip = NULL,
auto_highlight = FALSE,
highlight_colour = "#AAFFFFFF",
palette = "viridis",
na_colour = "#808080FF",
legend = FALSE,
legend_options = NULL,
legend_format = NULL,
update_view = TRUE,
focus_layer = FALSE,
digits = 6,
transitions = NULL,
)

## Arguments

map a mapdeck map object data to be used in the layer. All coordinates are expected to be EPSG:4326 (WGS 84) coordinate system single value specifying an id for the layer. Use this value to distinguish between shape layers of the same type. Layers with the same id are likely to conflict and not plot correctly vector of longitude and latitude columns, and optionally an elevation column, or an sfc column vector of longitude and latitude columns, and optionally an elevatino column, or an sfc column an id value in data to identify layers when interacting in Shiny apps. variable or hex colour to use as the ending stroke colour. width of the line in metres Either a string specifying the column of data containing the opacity of each shape, or a single value in [0,255], or [0, 1), to be applied to all the shapes. Default 255. If a hex-string is used as the colour, this argument is ignored and you should include the alpha on the hex string column of data, or a single value indicating the number of arcs generated in each animation the speed of animation the length of trail of each arc variable of data containing text or HTML to render as a tooltip logical indicating if the shape under the mouse should auto-highlight hex string colour to use for highlighting. Must contain the alpha component. string or matrix. String will be one of colourvalues::colour_palettes(). A matrix must have at least 5 rows, and 3 or 4 columns of values between [0, 255], where the 4th column represents the alpha. You can use a named list to specify a different palette for different colour options (where available), e.g. list(fill_colour = "viridis", stroke_colour = "inferno") hex string colour to use for NA values either a logical indiciating if the legend(s) should be displayed, or a named list indicating which colour attributes should be included in the legend. A list of options for controlling the legend. A list containing functions to apply to legend values. See section legend logical indicating if the map should update the bounds to include this layer logical indicating if the map should update the bounds to only include this layer number of digits for rounding coordinates list specifying the duration of transitions. radius of the brush in metres. Default NULL. If supplied, the arcs will only show if the origin or destination are within the radius of the mouse. If NULL, all arcs are displayed

## Details

add_line supports POINT sf objects

MULTIPOINT objects will be treated as single points. That is, if an sf object has one row with a MULTIPOINT object consisting of two points, this will be expanded to two rows of single POINTs. Therefore, if the origin is a MULTIPOINT of two points, and the destination is a single POINT, the code will error as there will be an uneven number of rows

## Examples

# \donttest{

key <- 'abc'
set_token( key )

url <- 'https://raw.githubusercontent.com/plotly/datasets/master/2011_february_aa_flight_paths.csv'
flights$id <- seq_len(nrow(flights)) flights$stroke <- sample(1:3, size = nrow(flights), replace = T)

mapdeck(style = mapdeck_style("dark"), pitch = 45 ) %>%
data = flights
, layer_id = "line_layer"
, origin = c("start_lon", "start_lat")
, destination = c("end_lon", "end_lat")
, stroke_colour = "airport1"
, stroke_width = "stroke"
, auto_highlight = TRUE
, trail_length = 1
, animation_speed = 1
)#> animated_line is an experimental layer and the function may change without warning
## Using a 2-sfc-column sf object

sf_flights <- sfheaders::sf_point( flights, x = "start_lon", y = "start_lat", keep = TRUE )
destination <- sfheaders::sfc_point( flights, x = "end_lon", y = "end_lat" )

sf_flights\$destination <- destination

mapdeck() %>%