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.
Returns
sf simple features or GeoJSON
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:
input "about:config " to your firefox address bar and hit enter
make sure your "dom.allow_scripts_to_close_windows" is true
Examples
## 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)