| addVectorgrid | R Documentation |
Displays large polygon/line datasets as tiled vector features using
Leaflet.VectorGrid
(L.vectorGrid.slicer). This is more efficient than
addPolygons for big GeoJSON.
addVectorgrid(
map,
data,
layerId = NULL,
group = NULL,
featureId = NULL,
popup = NULL,
stroke = TRUE,
color = "#03F",
weight = 5,
opacity = 0.5,
fill = TRUE,
fillColor = color,
fillOpacity = 0.2,
dashArray = NULL,
options = pathOptions(),
interactive = TRUE
)
map |
a map widget object created from |
data |
An |
layerId |
the layer id |
group |
the name of the group the newly created layers should belong to
(for |
featureId |
Formula or vector of unique feature ids (used for highlight
and the Shiny click |
popup |
Formula, column name or character vector with HTML for the click popup. |
stroke |
whether to draw stroke along the path (e.g., the borders of polygons or circles) |
color |
stroke color |
weight |
stroke width in pixels |
opacity |
stroke opacity (or layer opacity for tile layers) |
fill |
whether to fill the path with color (e.g., filling on polygons or circles) |
fillColor |
fill color |
fillOpacity |
fill opacity |
dashArray |
a string that defines the stroke dash pattern |
options |
a list of extra options for tile layers, popups, paths (circles, rectangles, polygons, ...), or other map elements |
interactive |
Whether the layer fires mouse events. Default |
In Shiny a click updates input$MAPID_vectorgrid_click with
id, group, lat, lng and properties.
the new map object
https://github.com/Leaflet/Leaflet.VectorGrid
Other Vectorgrid Functions:
addProtobuf(),
clearVectorgrid(),
removeVectorgrid(),
vectorStyling()
## Not run:
library(leaflet)
library(sf)
nc <- st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
leaflet() %>%
addTiles() %>%
addVectorgrid(
data = nc,
layerId = "nc",
featureId = ~NAME,
popup = ~NAME,
color = "black",
fillColor = "#4daf4a",
weight = 1
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.