Add a line layer to a map
add_line_layer.Rd
Add a line layer to a map
Usage
add_line_layer(
map,
id,
source,
source_layer = NULL,
line_blur = NULL,
line_color = NULL,
line_dasharray = NULL,
line_gap_width = NULL,
line_offset = NULL,
line_opacity = NULL,
line_pattern = NULL,
line_sort_key = NULL,
line_translate = NULL,
line_translate_anchor = "map",
line_width = NULL,
visibility = "visible",
slot = NULL,
min_zoom = NULL,
max_zoom = NULL,
popup = NULL,
tooltip = NULL,
hover_options = NULL,
before_id = NULL,
filter = NULL
)
Arguments
- map
A map object created by the
mapboxgl
ormaplibre
functions.- id
A unique ID for the layer.
- source
The ID of the source, alternatively an sf object (which will be converted to a GeoJSON source) or a named list that specifies
type
andurl
for a remote source.- source_layer
The source layer (for vector sources).
- line_blur
Amount to blur the line.
- line_color
The color with which the line will be drawn.
- line_dasharray
Specifies the lengths of the alternating dashes and gaps that form the dash pattern.
- line_gap_width
The width of the gap between a dashed line's individual dashes.
- line_offset
The line's offset.
- line_opacity
The opacity at which the line will be drawn.
- line_pattern
Name of image in sprite to use for drawing image fills.
- line_sort_key
Sorts features in ascending order based on this value.
- line_translate
The geometry's offset. Values are
c(x, y)
where negatives indicate left and up.- line_translate_anchor
Controls the frame of reference for
line-translate
.- line_width
Stroke thickness.
- visibility
Whether this layer is displayed.
- slot
An optional slot for layer order. Only available when using the Mapbox Standard style.
- min_zoom
The minimum zoom level for the layer.
- max_zoom
The maximum zoom level for the layer.
- popup
A column name containing information to display in a popup on click. Columns containing HTML will be parsed.
- tooltip
A column name containing information to display in a tooltip on hover. Columns containing HTML will be parsed.
- hover_options
A named list of options for highlighting features in the layer on hover.
- before_id
The name of the layer that this layer appears "before", allowing you to insert layers below other layers in your basemap (e.g. labels)
- filter
An optional filter expression to subset features in the layer.
Examples
if (FALSE) { # \dontrun{
library(mapgl)
library(tigris)
loving_roads <- roads("TX", "Loving")
maplibre(style = maptiler_style("backdrop")) |>
fit_bounds(loving_roads) |>
add_line_layer(
id = "tracks",
source = loving_roads,
line_color = "navy",
line_opacity = 0.7
)
} # }