Add a line layer to a map
add_line_layer(
map,
id,
source,
source_layer = NULL,
line_blur = NULL,
line_cap = NULL,
line_color = NULL,
line_dasharray = NULL,
line_emissive_strength = NULL,
line_gap_width = NULL,
line_gradient = NULL,
line_join = NULL,
line_miter_limit = NULL,
line_occlusion_opacity = NULL,
line_offset = NULL,
line_opacity = NULL,
line_pattern = NULL,
line_round_limit = NULL,
line_sort_key = NULL,
line_translate = NULL,
line_translate_anchor = "map",
line_trim_color = NULL,
line_trim_fade_range = NULL,
line_trim_offset = NULL,
line_width = NULL,
line_z_offset = NULL,
visibility = "visible",
slot = NULL,
min_zoom = NULL,
max_zoom = NULL,
popup = NULL,
tooltip = NULL,
hover_options = NULL,
before_id = NULL,
filter = NULL
)
The modified map object with the new line layer added.
A map object created by the mapboxgl
or maplibre
functions.
A unique ID for the layer.
The ID of the source, alternatively an sf object (which will be
converted to a GeoJSON source) or a named list that specifies type
and
url
for a remote source.
The source layer (for vector sources).
Amount to blur the line, in pixels.
The display of line endings. One of "butt", "round", "square".
The color with which the line will be drawn.
Specifies the lengths of the alternating dashes and gaps that form the dash pattern.
Controls the intensity of light emitted on the source features.
Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap.
A gradient used to color a line feature at various distances along its length.
The display of lines when joining.
Used to automatically convert miter joins to bevel joins for sharp angles.
Opacity multiplier of the line part that is occluded by 3D objects.
The line's offset.
The opacity at which the line will be drawn.
Name of image in sprite to use for drawing image lines.
Used to automatically convert round joins to miter joins for shallow angles.
Sorts features in ascending order based on this value.
The geometry's offset. Values are c(x, y)
where
negatives indicate left and up, respectively.
Controls the frame of reference for line-translate
.
The color to be used for rendering the trimmed line section.
The fade range for the trim-start and trim-end points.
The line part between c(trim_start, trim_end)
will be
painted using line_trim_color
.
Stroke thickness.
Vertical offset from ground, in meters.
Whether this layer is displayed.
An optional slot for layer order.
The minimum zoom level for the layer.
The maximum zoom level for the layer.
A column name containing information to display in a popup on click. Columns containing HTML will be parsed.
A column name containing information to display in a tooltip on hover. Columns containing HTML will be parsed.
A named list of options for highlighting features in the layer on hover.
The name of the layer that this layer appears "before", allowing you to insert layers below other layers in your basemap (e.g. labels)
An optional filter expression to subset features in the layer.
if (FALSE) {
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
)
}
Run the code above in your browser using DataLab