addLocalFile {leafem}R Documentation

Add vector data to leaflet map directly from the file system

Description

Add vector data to leaflet map directly from the file system

Usage

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
)

Arguments

map

a mapview or leaflet object.

file

file path to the file to be added to map. NOTE: will be reprojected on-the-fly if not in "longlat".

layerId

the layer id.

group

the group name for the file to be added to map.

popup

either a logical of whether to show the feature properties (fields) in popups or the name of the field to show in popups.

label

name of the field to be shown as a tooltip.

radius

the size of the circle markers.

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.

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.

Examples

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)
}


[Package leafem version 0.2.3 Index]