editMap: Interactively Edit a Map

Description Usage Arguments Details Value Examples

View source: R/edit.R

Description

Interactively Edit a Map

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
editMap(x, ...)

## S3 method for class 'leaflet'
editMap(
  x = NULL,
  targetLayerId = NULL,
  sf = TRUE,
  ns = "mapedit-edit",
  record = FALSE,
  viewer = shiny::paneViewer(),
  crs = 4326,
  title = "Edit Map",
  editor = c("leaflet.extras", "leafpm"),
  editorOptions = list(),
  ...
)

## S3 method for class 'mapview'
editMap(
  x = NULL,
  targetLayerId = NULL,
  sf = TRUE,
  ns = "mapedit-edit",
  record = FALSE,
  viewer = shiny::paneViewer(),
  crs = 4326,
  title = "Edit Map",
  editor = c("leaflet.extras", "leafpm"),
  editorOptions = list(),
  ...
)

## S3 method for class ''NULL''
editMap(x, editor = c("leaflet.extras", "leafpm"), editorOptions = list(), ...)

Arguments

x

leaflet or mapview map to edit

...

other arguments for leafem::addFeatures() when using editMap.NULL or selectFeatures

targetLayerId

string name of the map layer group to use with edit

sf

logical return simple features. The default is TRUE. If sf = FALSE, GeoJSON will be returned.

ns

string name for the Shiny namespace to use. The ns is unlikely to require a change.

record

logical to record all edits for future playback.

viewer

function for the viewer. See Shiny viewer. NOTE: when using browserViewer(browser = getOption("browser")) to open the app in the default browser, the browser window will automatically close when closing the app (by pressing "done" or "cancel") in most browsers. Firefox is an exception. See Details for instructions on how to enable this behaviour in Firefox.

crs

see st_crs.

title

string to customize the title of the UI window. The default is "Edit Map".

editor

character either "leaflet.extras" or "leafpm"

editorOptions

list of options suitable for passing to either leaflet.extras::addDrawToolbar or leafpm::addPmToolbar.

Details

When setting viewer = browserViewer(browser = getOption("browser")) and the systems default browser is Firefox, the browser window will likely not automatically close when the app is closed (by pressing "done" or "cancel"). To enable automatic closing of tabs/windows in Firefox try the following:

Value

sf simple features or GeoJSON

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
library(leaflet)
library(mapedit)
editMap(leaflet() %>% addTiles())

## End(Not run)
## Not run: 
  # demonstrate Leaflet.Draw on a layer
  library(sf)
  library(mapview)
  library(leaflet.extras)
  library(mapedit)

  # ?sf::sf
  pol = st_sfc(
    st_polygon(list(cbind(c(0,3,3,0,0),c(0,0,3,3,0)))),
    crs = 4326
  )
  mapview(pol) %>%
    editMap(targetLayerId = "pol")

  mapview(franconia[1:2,]) %>%
    editMap(targetLayerId = "franconia[1:2, ]")

## End(Not run)

mapedit documentation built on Feb. 3, 2020, 1:07 a.m.