
Add vector data to leaflet map directly from the file system
addLocalFile(
map,
file,
layerId = NULL,
group = NULL,
popup = NULL,
label = NULL,
radius = 10,
stroke = TRUE,
color = "#03F",
weight = 5,
opacity = 0.5,
fill = TRUE,
fillColor = color,
fillOpacity = 0.2,
dashArray = NULL,
options = NULL
)
a mapview or leaflet object.
file path to the file to be added to map
. NOTE: will be
reprojected on-the-fly if not in "longlat".
the layer id.
the group name for the file to be added to map
.
either a logical of whether to show the feature properties (fields) in popups or the name of the field to show in popups.
name of the field to be shown as a tooltip.
the size of the circle markers.
whether to draw stroke along the path (e.g. the borders of polygons or circles).
stroke color.
stroke width in pixels.
stroke opacity.
whether to fill the path with color (e.g. filling on polygons or circles).
fill color.
fill opacity.
a string that defines the stroke dash pattern.
a list of extra options for tile layers, popups, paths (circles, rectangles, polygons, ...), or other map elements.
if (interactive()) {
library(leafem)
library(leaflet)
library(sf)
destfile = tempfile(fileext = ".gpkg")
st_write(st_as_sf(gadmCHE), dsn = destfile)
leaflet() %>%
addTiles() %>%
addLocalFile(destfile, popup = TRUE)
}
Run the code above in your browser using DataLab