mapboxgl_view | R Documentation |
This function provides a quick way to visualize sf geometries using Mapbox GL JS. It automatically detects the geometry type and applies appropriate styling.
mapboxgl_view(
data,
color = "navy",
column = NULL,
n = NULL,
palette = viridisLite::viridis,
style = mapbox_style("light"),
...
)
data |
An sf object to visualize |
color |
The color used to visualize points, lines, or polygons if |
column |
The name of the column to visualize. If NULL (default), geometries are shown with default styling. |
n |
Number of quantile breaks for numeric columns. If specified, uses step_expr() instead of interpolate(). |
palette |
Color palette function that takes n and returns a character vector of colors. Defaults to viridisLite::viridis. |
style |
The Mapbox style to use. Defaults to mapbox_style("light"). |
... |
Additional arguments passed to mapboxgl() |
A Mapbox GL map object
## Not run:
library(sf)
nc <- st_read(system.file("shape/nc.shp", package = "sf"))
# Basic view
mapboxgl_view(nc)
# View with column visualization
mapboxgl_view(nc, column = "AREA")
# View with quantile breaks
mapboxgl_view(nc, column = "AREA", n = 5)
# Custom palette examples
mapboxgl_view(nc, column = "AREA", palette = viridisLite::mako)
mapboxgl_view(nc, column = "AREA", palette = function(n) RColorBrewer::brewer.pal(n, "RdYlBu"))
mapboxgl_view(nc, column = "AREA", palette = colorRampPalette(c("red", "white", "blue")))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.