Learn R Programming

deckgl (version 0.2.5)

add_line_layer: Add a line layer to the deckgl widget

Description

The LineLayer renders flat lines joining pairs of source and target points, specified as latitude/longitude coordinates.

Usage

add_line_layer(deckgl, id = "line-layer", data = NULL,
  properties = list(), ...)

Arguments

deckgl

deckgl widget

id

id of the layer

data

url to fetch data from or data object

properties

named list of properties with names corresponding to the properties defined in the deckgl-api-reference for the given layer class, additionally there is a getTooltip property (callback) showing a tooltip when the mouse enters an object, e. g. getTooltip = JS("object => object.name")

...

more properties (will be added to the properties object), useful if you want to use a properties object for more than one layer

See Also

https://deck.gl/#/documentation/deckgl-api-reference/layers/line-layer

Examples

Run this code
# NOT RUN {
## @knitr line-layer
data("bart_segments")

properties <- list(
  pickable = TRUE,
  getWidth = 12,
  getSourcePosition = ~from_lng + from_lat,
  getTargetPosition = ~to_lng + to_lat,
  getColor = JS("d => [Math.sqrt(d.inbound + d.outbound), 140, 0]"),
  getTooltip = JS("object => `${object.from_name} to ${object.to_name}`")
)

deck <- deckgl(zoom = 10, pitch = 20) %>%
  add_line_layer(data = bart_segments, properties = properties) %>%
  add_mapbox_basemap()

if (interactive()) deck
# }

Run the code above in your browser using DataLab