diff --git a/NAMESPACE b/NAMESPACE index 5660d23..22a1e35 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -57,6 +57,8 @@ export(drawPolylineOptions) export(drawRectangleOptions) export(drawShapeOptions) export(editToolbarOptions) +export(edithandlersOptions) +export(edittoolbarOptions) export(enableMeasurePath) export(enableTileCaching) export(gpsOptions) diff --git a/R/draw.R b/R/draw.R index 98aa16e..4aac7d9 100644 --- a/R/draw.R +++ b/R/draw.R @@ -29,6 +29,8 @@ drawDependencies <- function(drag = TRUE) { #' @param singleFeature When set to TRUE, only one feature can be drawn at a time, the previous ones being removed. #' @param toolbar See \code{\link{toolbarOptions}}. Set to \code{NULL} to take Leaflets default values. #' @param handlers See \code{\link{handlersOptions}}. Set to \code{NULL} to take Leaflets default values. +#' @param edittoolbar See \code{\link{edittoolbarOptions}}. Set to \code{NULL} to take Leaflets default values. +#' @param edithandlers See \code{\link{edithandlersOptions}}. Set to \code{NULL} to take Leaflets default values. #' @param drag When set to \code{TRUE}, the drawn features will be draggable during editing, utilizing #' the \code{Leaflet.Draw.Drag} plugin. Otherwise, this library will not be included. #' @@ -92,13 +94,18 @@ addDrawToolbar <- function( singleFeature = FALSE, toolbar = NULL, handlers = NULL, + edittoolbar = NULL, + edithandlers = NULL, drag = TRUE) { + if (!is.null(targetGroup) && !is.null(targetLayerId)) { stop("To edit existing features either specify a targetGroup or a targetLayerId, but not both") } if (!inherits(toolbar, "list")) toolbar <- NULL if (!inherits(handlers, "list")) handlers <- NULL + if (!inherits(edittoolbar, "list")) edittoolbar <- NULL + if (!inherits(edithandlers, "list")) edithandlers <- NULL map$dependencies <- c(map$dependencies, drawDependencies(drag)) @@ -132,7 +139,9 @@ addDrawToolbar <- function( )), edit = editOptions, toolbar = toolbar, - handlers = handlers + handlers = handlers, + edittoolbar = edittoolbar, + edithandlers = edithandlers ) leaflet::invokeMethod( diff --git a/R/drawOptions.R b/R/drawOptions.R index fc897d4..60914f0 100644 --- a/R/drawOptions.R +++ b/R/drawOptions.R @@ -237,6 +237,7 @@ editToolbarOptions <- function( #' @param circle List of options for circle tooltips. #' @param marker List of options for marker tooltips. #' @param circlemarker List of options for circlemarker tooltips. +#' @param simpleshape List of options for simpleshape tooltips. #' @export #' @examples \dontrun{ #' library(leaflet) @@ -279,6 +280,9 @@ handlersOptions <- function( ), circlemarker = list( tooltipStart = "Click and drag to draw circle." + ), + simpleshape = list( + tooltipEnd = "Release mouse to finish drawing." )) { leaflet::filterNULL(list( polyline = list( @@ -302,7 +306,8 @@ handlersOptions <- function( tooltip = list(start = circle$tooltipStart) ), marker = list(tooltip = list(start = marker$tooltipStart)), - circlemarker = list(tooltip = list(start = circlemarker$tooltipStart)) + circlemarker = list(tooltip = list(start = circlemarker$tooltipStart)), + simpleshape = list(tooltip = list(end = simpleshape$tooltipEnd)) )) } @@ -377,3 +382,73 @@ toolbarOptions <- function( ) )) } + + + + + + + +#' Options for editing edit handlers +#' @description Customize edit handlers for \code{\link{addDrawToolbar}} +#' @param edit List of options for editing tooltips. +#' @param remove List of options for removing tooltips. +#' @export +edithandlersOptions <- function( + edit = list( + tooltipText = "Drag handles or markers to edit features.", + tooltipSubtext = "Click cancel to undo changes." + ), + remove = list( + tooltipText = "Click on a feature to remove." + )) { + + leaflet::filterNULL(list( + edit = list( + tooltip = list( + text = edit$tooltipText, + subtext = edit$tooltipSubtext + ) + ), + remove = list( + tooltip = list( + text = remove$tooltipText + ) + ) + )) +} + + + +#' Options for editing the toolbar +#' @description Customize the edit toolbar for \code{\link{addDrawToolbar}} +#' @param actions List of options for edit action tooltips. +#' @param buttons List of options for edit button tooltips. +#' @export +edittoolbarOptions <- function( + actions = list( + save = list( + title = "Save changes", + text = "Save" + ), + cancel = list( + title = "Cancel editing, discards all changes", + text = "Cancel" + ), + clearAll = list( + title = "Clear all layers", + text = "Clear All" + ) + ), + buttons = list( + edit = "Edit layers", + editDisabled = "No layers to edit", + remove = "Delete layers", + removeDisabled = "No layers to delete" + )) { + + leaflet::filterNULL(list( + actions = actions, + buttons = buttons + )) +} diff --git a/inst/htmlwidgets/bindings/lfx-draw-bindings.js b/inst/htmlwidgets/bindings/lfx-draw-bindings.js index 52c338b..9d5f13c 100644 --- a/inst/htmlwidgets/bindings/lfx-draw-bindings.js +++ b/inst/htmlwidgets/bindings/lfx-draw-bindings.js @@ -93,6 +93,19 @@ LeafletWidget.methods.addDrawToolbar = function(targetLayerId, editOptions.featureGroup = editableFeatureGroup; options.edit = editOptions; + + if (options && options.edittoolbar) { + var rtool = options.edittoolbar; + var tooldef = L.drawLocal.draw.toolbar; + L.drawLocal.edit.toolbar.buttons = Object.assign({}, tooldef.buttons, rtool.buttons); + L.drawLocal.edit.toolbar.actions = Object.assign({}, tooldef.actions, rtool.actions); + } + + if (options && options.edithandlers) { + var rhand = options.edithandlers; + L.drawLocal.edit.handlers.edit = Object.assign({}, rhand.buttons, rtool.edit); + L.drawLocal.edit.handlers.remove = Object.assign({}, rhand.actions, rtool.remove); + } } // Set Toolbar / Handlers options if provided. Changes the default values. @@ -114,6 +127,7 @@ LeafletWidget.methods.addDrawToolbar = function(targetLayerId, L.drawLocal.draw.handlers.polygon = Object.assign({}, handldef.polygon, rhand.polygon); L.drawLocal.draw.handlers.polyline = Object.assign({}, handldef.polyline, rhand.polyline); L.drawLocal.draw.handlers.rectangle = Object.assign({}, handldef.rectangle, rhand.rectangle); + L.drawLocal.draw.handlers.simpleshape = Object.assign({}, handldef.simpleshape, rhand.simpleshape); } // Create new Drawing Control diff --git a/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js b/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js index a5d688d..a3ac3a3 100644 --- a/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js +++ b/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js @@ -1 +1 @@ -LeafletWidget.methods.addDrawToolbar=function(e,a,r){function t(e,a,r,t,o){return function(n){if(HTMLWidgets.shinyMode){var d=$.extend({id:a,category:o,".nonce":Math.random()},null!==r?{group:r}:null,n.target._latlngs?{latlngs:n.target._latlngs.flat()}:n.target._latlng,void 0!==n.target._mRadius?{radius:n.target._mRadius}:{});Shiny.onInputChange(e+"_"+t,d)}}}(function(){var o,n=this;if(n.drawToolbar&&(n.drawToolbar.remove(n),delete n.drawToolbar),e){if(!(o=n.layerManager.getLayer("geojson",e)))throw"GeoJSON layer with ID "+e+" not Found";n._editableGeoJSONLayerId=e}else a||(a="editableFeatureGroup"),o=n.layerManager.getLayerGroup(a,!0),n._editableFeatureGroupName=a;if(r&&r.draw&&r.draw.marker&&r.draw.marker.markerIcon&&r.draw.marker.markerIconFunction&&(r.draw.marker.icon=r.draw.marker.markerIconFunction(r.draw.marker.markerIcon)),!$.isEmptyObject(r.edit)){var d={};r.edit.remove||(d.remove=!1),r.edit.edit?$.isEmptyObject(r.edit.selectedPathOptions)||(d.edit={},d.edit.selectedPathOptions=r.edit.selectedPathOptions):d.edit=!1,$.isEmptyObject(r.edit.poly)||(d.poly=r.edit.poly),d.featureGroup=o,r.edit=d}if(r&&r.toolbar){var i=r.toolbar,l=L.drawLocal.draw.toolbar;L.drawLocal.draw.toolbar.buttons=Object.assign({},l.buttons,i.buttons),L.drawLocal.draw.toolbar.actions=Object.assign({},l.actions,i.actions),L.drawLocal.draw.toolbar.finish=Object.assign({},l.finish,i.finish),L.drawLocal.draw.toolbar.undo=Object.assign({},l.undo,i.undo)}if(r&&r.handlers){var s=r.handlers,u=L.drawLocal.draw.handlers;L.drawLocal.draw.handlers.circle=Object.assign({},u.circle,s.circle),L.drawLocal.draw.handlers.circlemarker=Object.assign({},u.circlemarker,s.circlemarker),L.drawLocal.draw.handlers.marker=Object.assign({},u.marker,s.marker),L.drawLocal.draw.handlers.polygon=Object.assign({},u.polygon,s.polygon),L.drawLocal.draw.handlers.polyline=Object.assign({},u.polyline,s.polyline),L.drawLocal.draw.handlers.rectangle=Object.assign({},u.rectangle,s.rectangle)}n.drawToolbar=new L.Control.Draw(r),n.drawToolbar.eventHandler={},n.drawToolbar.addTo(n),n.drawToolbar.eventHandler.onDrawStart=function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_start",{feature_type:e.layerType,nonce:Math.random()})},n.on(L.Draw.Event.DRAWSTART,n.drawToolbar.eventHandler.onDrawStart),n.drawToolbar.eventHandler.onDrawStop=function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_stop",{feature_type:e.layerType,nonce:Math.random()})},n.on(L.Draw.Event.DRAWSTOP,n.drawToolbar.eventHandler.onDrawStop),n.drawToolbar.eventHandler.onCreated=function(e){r.draw.singleFeature&&o.getLayers().length>0&&o.clearLayers();var d=e.layer;o.addLayer(d);var i=L.stamp(d);if(d.feature={type:"Feature",properties:{_leaflet_id:i,feature_type:e.layerType}},"function"==typeof d.getRadius&&(d.feature.properties.radius=d.getRadius()),HTMLWidgets.shinyMode){var l=e.layerType;["rectangle","polygon","circle"].includes(l)?l="shape":"circlemarker"===l&&(l="marker"),d.on("click",t(n.id,i,a,l+"_draw_click",l),n),d.on("mouseover",t(n.id,i,a,l+"_draw_mouseover",l),n),d.on("mouseout",t(n.id,i,a,l+"_draw_mouseout",l),n),Shiny.onInputChange(n.id+"_draw_new_feature",d.toGeoJSON(),{priority:"event"}),Shiny.onInputChange(n.id+"_draw_all_features",o.toGeoJSON(),{priority:"event"})}},n.on(L.Draw.Event.CREATED,n.drawToolbar.eventHandler.onCreated),n.drawToolbar.eventHandler.onEditstart=function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_editstart",!0,{priority:"event"})},n.on(L.Draw.Event.EDITSTART,n.drawToolbar.eventHandler.onEditstart),n.drawToolbar.eventHandler.onEditstop=function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_editstop",!0,{priority:"event"})},n.on(L.Draw.Event.EDITSTOP,n.drawToolbar.eventHandler.onEditstop),n.drawToolbar.eventHandler.onEdited=function(e){var a=e.layers;a.eachLayer((function(e){var a=L.stamp(e);e.feature||(e.feature={type:"Feature"}),e.feature.properties||(e.feature.properties={}),e.feature.properties._leaflet_id=a,e.feature.properties.layerId=e.options.layerId,"function"==typeof e.getRadius&&(e.feature.properties.radius=e.getRadius())})),HTMLWidgets.shinyMode&&(Shiny.onInputChange(n.id+"_draw_edited_features",a.toGeoJSON(),{priority:"event"}),Shiny.onInputChange(n.id+"_draw_all_features",o.toGeoJSON(),{priority:"event"}))},n.on(L.Draw.Event.EDITED,n.drawToolbar.eventHandler.onEdited),n.drawToolbar.eventHandler.onDeletestart=function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_deletestart",!0,{priority:"event"})},n.on(L.Draw.Event.DELETESTART,n.drawToolbar.eventHandler.onDeletestart),n.drawToolbar.eventHandler.onDeletestop=function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_deletestop",!0,{priority:"event"})},n.on(L.Draw.Event.DELETESTOP,n.drawToolbar.eventHandler.onDeletestop),n.drawToolbar.eventHandler.onDeleted=function(e){var a=e.layers;a.eachLayer((function(e){var a=L.stamp(e);e.feature||(e.feature={type:"Feature"}),e.feature.properties||(e.feature.properties={}),e.feature.properties._leaflet_id=a,e.feature.properties.layerId=e.options.layerId,"function"==typeof e.getRadius&&(e.feature.properties.radius=e.getRadius())})),HTMLWidgets.shinyMode&&(Shiny.onInputChange(n.id+"_draw_deleted_features",a.toGeoJSON(),{priority:"event"}),Shiny.onInputChange(n.id+"_draw_all_features",o.toGeoJSON(),{priority:"event"}))},n.on(L.Draw.Event.DELETED,n.drawToolbar.eventHandler.onDeleted)}).call(this)},LeafletWidget.methods.removeDrawToolbar=function(e){(function(){var a=this;a.drawToolbar&&(a.off(L.Draw.Event.DRAWSTART,a.drawToolbar.eventHandler.onDrawStart),a.off(L.Draw.Event.DRAWSTOP,a.drawToolbar.eventHandler.onDrawStop),a.off(L.Draw.Event.CREATED,a.drawToolbar.eventHandler.onCreated),a.off(L.Draw.Event.EDITSTART,a.drawToolbar.eventHandler.onEditstart),a.off(L.Draw.Event.EDITSTOP,a.drawToolbar.eventHandler.onEditstop),a.off(L.Draw.Event.EDITED,a.drawToolbar.eventHandler.onEdited),a.off(L.Draw.Event.DELETESTART,a.drawToolbar.eventHandler.onDeletestart),a.off(L.Draw.Event.DELETESTOP,a.drawToolbar.eventHandler.onDeletestop),a.off(L.Draw.Event.DELETED,a.drawToolbar.eventHandler.onDeleted),a.drawToolbar.remove(a),delete a.drawToolbar),a._editableFeatureGroupName&&e&&a.layerManager.getLayerGroup(a._editableFeatureGroupName,!1).clearLayers(),a._editableFeatureGroupName=null,a._editableGeoJSONLayerId&&e&&a.layerManager.removeLayer("geojson",a._editableGeoJSONLayerId),a._editableGeoJSONLayerId=null}).call(this)},LeafletWidget.methods.getDrawnItems=function(){var e,a=this;return a._editableGeoJSONLayerId?e=a.layerManager.getLayer("geojson",a._editableGeoJSONLayerId):a._editableFeatureGroupName&&(e=a.layerManager.getLayerGroup(a._editableFeatureGroupName,!1)),e?e.toGeoJSON():null}; \ No newline at end of file +LeafletWidget.methods.addDrawToolbar=function(e,a,r){function t(e,a,r,t,o){return function(n){if(HTMLWidgets.shinyMode){var d=$.extend({id:a,category:o,".nonce":Math.random()},null!==r?{group:r}:null,n.target._latlngs?{latlngs:n.target._latlngs.flat()}:n.target._latlng,void 0!==n.target._mRadius?{radius:n.target._mRadius}:{});Shiny.onInputChange(e+"_"+t,d)}}}(function(){var o,n=this;if(n.drawToolbar&&(n.drawToolbar.remove(n),delete n.drawToolbar),e){if(!(o=n.layerManager.getLayer("geojson",e)))throw"GeoJSON layer with ID "+e+" not Found";n._editableGeoJSONLayerId=e}else a||(a="editableFeatureGroup"),o=n.layerManager.getLayerGroup(a,!0),n._editableFeatureGroupName=a;if(r&&r.draw&&r.draw.marker&&r.draw.marker.markerIcon&&r.draw.marker.markerIconFunction&&(r.draw.marker.icon=r.draw.marker.markerIconFunction(r.draw.marker.markerIcon)),!$.isEmptyObject(r.edit)){var d={};if(r.edit.remove||(d.remove=!1),r.edit.edit?$.isEmptyObject(r.edit.selectedPathOptions)||(d.edit={},d.edit.selectedPathOptions=r.edit.selectedPathOptions):d.edit=!1,$.isEmptyObject(r.edit.poly)||(d.poly=r.edit.poly),d.featureGroup=o,r.edit=d,r&&r.edittoolbar){var i=r.edittoolbar,l=L.drawLocal.draw.toolbar;L.drawLocal.edit.toolbar.buttons=Object.assign({},l.buttons,i.buttons),L.drawLocal.edit.toolbar.actions=Object.assign({},l.actions,i.actions)}if(r&&r.edithandlers){var s=r.edithandlers;L.drawLocal.edit.handlers.edit=Object.assign({},s.buttons,i.edit),L.drawLocal.edit.handlers.remove=Object.assign({},s.actions,i.remove)}}if(r&&r.toolbar&&(i=r.toolbar,l=L.drawLocal.draw.toolbar,L.drawLocal.draw.toolbar.buttons=Object.assign({},l.buttons,i.buttons),L.drawLocal.draw.toolbar.actions=Object.assign({},l.actions,i.actions),L.drawLocal.draw.toolbar.finish=Object.assign({},l.finish,i.finish),L.drawLocal.draw.toolbar.undo=Object.assign({},l.undo,i.undo)),r&&r.handlers){s=r.handlers;var w=L.drawLocal.draw.handlers;L.drawLocal.draw.handlers.circle=Object.assign({},w.circle,s.circle),L.drawLocal.draw.handlers.circlemarker=Object.assign({},w.circlemarker,s.circlemarker),L.drawLocal.draw.handlers.marker=Object.assign({},w.marker,s.marker),L.drawLocal.draw.handlers.polygon=Object.assign({},w.polygon,s.polygon),L.drawLocal.draw.handlers.polyline=Object.assign({},w.polyline,s.polyline),L.drawLocal.draw.handlers.rectangle=Object.assign({},w.rectangle,s.rectangle),L.drawLocal.draw.handlers.simpleshape=Object.assign({},w.simpleshape,s.simpleshape)}n.drawToolbar=new L.Control.Draw(r),n.drawToolbar.eventHandler={},n.drawToolbar.addTo(n),n.drawToolbar.eventHandler.onDrawStart=function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_start",{feature_type:e.layerType,nonce:Math.random()})},n.on(L.Draw.Event.DRAWSTART,n.drawToolbar.eventHandler.onDrawStart),n.drawToolbar.eventHandler.onDrawStop=function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_stop",{feature_type:e.layerType,nonce:Math.random()})},n.on(L.Draw.Event.DRAWSTOP,n.drawToolbar.eventHandler.onDrawStop),n.drawToolbar.eventHandler.onCreated=function(e){r.draw.singleFeature&&o.getLayers().length>0&&o.clearLayers();var d=e.layer;o.addLayer(d);var i=L.stamp(d);if(d.feature={type:"Feature",properties:{_leaflet_id:i,feature_type:e.layerType}},"function"==typeof d.getRadius&&(d.feature.properties.radius=d.getRadius()),HTMLWidgets.shinyMode){var l=e.layerType;["rectangle","polygon","circle"].includes(l)?l="shape":"circlemarker"===l&&(l="marker"),d.on("click",t(n.id,i,a,l+"_draw_click",l),n),d.on("mouseover",t(n.id,i,a,l+"_draw_mouseover",l),n),d.on("mouseout",t(n.id,i,a,l+"_draw_mouseout",l),n),Shiny.onInputChange(n.id+"_draw_new_feature",d.toGeoJSON(),{priority:"event"}),Shiny.onInputChange(n.id+"_draw_all_features",o.toGeoJSON(),{priority:"event"})}},n.on(L.Draw.Event.CREATED,n.drawToolbar.eventHandler.onCreated),n.drawToolbar.eventHandler.onEditstart=function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_editstart",!0,{priority:"event"})},n.on(L.Draw.Event.EDITSTART,n.drawToolbar.eventHandler.onEditstart),n.drawToolbar.eventHandler.onEditstop=function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_editstop",!0,{priority:"event"})},n.on(L.Draw.Event.EDITSTOP,n.drawToolbar.eventHandler.onEditstop),n.drawToolbar.eventHandler.onEdited=function(e){var a=e.layers;a.eachLayer((function(e){var a=L.stamp(e);e.feature||(e.feature={type:"Feature"}),e.feature.properties||(e.feature.properties={}),e.feature.properties._leaflet_id=a,e.feature.properties.layerId=e.options.layerId,"function"==typeof e.getRadius&&(e.feature.properties.radius=e.getRadius())})),HTMLWidgets.shinyMode&&(Shiny.onInputChange(n.id+"_draw_edited_features",a.toGeoJSON(),{priority:"event"}),Shiny.onInputChange(n.id+"_draw_all_features",o.toGeoJSON(),{priority:"event"}))},n.on(L.Draw.Event.EDITED,n.drawToolbar.eventHandler.onEdited),n.drawToolbar.eventHandler.onDeletestart=function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_deletestart",!0,{priority:"event"})},n.on(L.Draw.Event.DELETESTART,n.drawToolbar.eventHandler.onDeletestart),n.drawToolbar.eventHandler.onDeletestop=function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(n.id+"_draw_deletestop",!0,{priority:"event"})},n.on(L.Draw.Event.DELETESTOP,n.drawToolbar.eventHandler.onDeletestop),n.drawToolbar.eventHandler.onDeleted=function(e){var a=e.layers;a.eachLayer((function(e){var a=L.stamp(e);e.feature||(e.feature={type:"Feature"}),e.feature.properties||(e.feature.properties={}),e.feature.properties._leaflet_id=a,e.feature.properties.layerId=e.options.layerId,"function"==typeof e.getRadius&&(e.feature.properties.radius=e.getRadius())})),HTMLWidgets.shinyMode&&(Shiny.onInputChange(n.id+"_draw_deleted_features",a.toGeoJSON(),{priority:"event"}),Shiny.onInputChange(n.id+"_draw_all_features",o.toGeoJSON(),{priority:"event"}))},n.on(L.Draw.Event.DELETED,n.drawToolbar.eventHandler.onDeleted)}).call(this)},LeafletWidget.methods.removeDrawToolbar=function(e){(function(){var a=this;a.drawToolbar&&(a.off(L.Draw.Event.DRAWSTART,a.drawToolbar.eventHandler.onDrawStart),a.off(L.Draw.Event.DRAWSTOP,a.drawToolbar.eventHandler.onDrawStop),a.off(L.Draw.Event.CREATED,a.drawToolbar.eventHandler.onCreated),a.off(L.Draw.Event.EDITSTART,a.drawToolbar.eventHandler.onEditstart),a.off(L.Draw.Event.EDITSTOP,a.drawToolbar.eventHandler.onEditstop),a.off(L.Draw.Event.EDITED,a.drawToolbar.eventHandler.onEdited),a.off(L.Draw.Event.DELETESTART,a.drawToolbar.eventHandler.onDeletestart),a.off(L.Draw.Event.DELETESTOP,a.drawToolbar.eventHandler.onDeletestop),a.off(L.Draw.Event.DELETED,a.drawToolbar.eventHandler.onDeleted),a.drawToolbar.remove(a),delete a.drawToolbar),a._editableFeatureGroupName&&e&&a.layerManager.getLayerGroup(a._editableFeatureGroupName,!1).clearLayers(),a._editableFeatureGroupName=null,a._editableGeoJSONLayerId&&e&&a.layerManager.removeLayer("geojson",a._editableGeoJSONLayerId),a._editableGeoJSONLayerId=null}).call(this)},LeafletWidget.methods.getDrawnItems=function(){var e,a=this;return a._editableGeoJSONLayerId?e=a.layerManager.getLayer("geojson",a._editableGeoJSONLayerId):a._editableFeatureGroupName&&(e=a.layerManager.getLayerGroup(a._editableFeatureGroupName,!1)),e?e.toGeoJSON():null}; \ No newline at end of file diff --git a/man/draw.Rd b/man/draw.Rd index fb7e35c..61d271f 100644 --- a/man/draw.Rd +++ b/man/draw.Rd @@ -20,6 +20,8 @@ addDrawToolbar( singleFeature = FALSE, toolbar = NULL, handlers = NULL, + edittoolbar = NULL, + edithandlers = NULL, drag = TRUE ) @@ -57,6 +59,10 @@ You can either set layerId or group or none but not both.} \item{handlers}{See \code{\link{handlersOptions}}. Set to \code{NULL} to take Leaflets default values.} +\item{edittoolbar}{See \code{\link{edittoolbarOptions}}. Set to \code{NULL} to take Leaflets default values.} + +\item{edithandlers}{See \code{\link{edithandlersOptions}}. Set to \code{NULL} to take Leaflets default values.} + \item{drag}{When set to \code{TRUE}, the drawn features will be draggable during editing, utilizing the \code{Leaflet.Draw.Drag} plugin. Otherwise, this library will not be included.} diff --git a/man/edithandlersOptions.Rd b/man/edithandlersOptions.Rd new file mode 100644 index 0000000..b6b754f --- /dev/null +++ b/man/edithandlersOptions.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/drawOptions.R +\name{edithandlersOptions} +\alias{edithandlersOptions} +\title{Options for editing edit handlers} +\usage{ +edithandlersOptions( + edit = list(tooltipText = "Drag handles or markers to edit features.", tooltipSubtext = + "Click cancel to undo changes."), + remove = list(tooltipText = "Click on a feature to remove.") +) +} +\arguments{ +\item{edit}{List of options for editing tooltips.} + +\item{remove}{List of options for removing tooltips.} +} +\description{ +Customize edit handlers for \code{\link{addDrawToolbar}} +} diff --git a/man/edittoolbarOptions.Rd b/man/edittoolbarOptions.Rd new file mode 100644 index 0000000..5d74753 --- /dev/null +++ b/man/edittoolbarOptions.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/drawOptions.R +\name{edittoolbarOptions} +\alias{edittoolbarOptions} +\title{Options for editing the toolbar} +\usage{ +edittoolbarOptions( + actions = list(save = list(title = "Save changes", text = "Save"), cancel = list(title + = "Cancel editing, discards all changes", text = "Cancel"), clearAll = list(title = + "Clear all layers", text = "Clear All")), + buttons = list(edit = "Edit layers", editDisabled = "No layers to edit", remove = + "Delete layers", removeDisabled = "No layers to delete") +) +} +\arguments{ +\item{actions}{List of options for edit action tooltips.} + +\item{buttons}{List of options for edit button tooltips.} +} +\description{ +Customize the edit toolbar for \code{\link{addDrawToolbar}} +} diff --git a/man/handlersOptions.Rd b/man/handlersOptions.Rd index 5896638..07f40b7 100644 --- a/man/handlersOptions.Rd +++ b/man/handlersOptions.Rd @@ -13,7 +13,8 @@ handlersOptions( rectangle = list(tooltipStart = "Click and drag to draw rectangle."), circle = list(tooltipStart = "Click map to place circle marker.", radius = "Radius"), marker = list(tooltipStart = "Click map to place marker."), - circlemarker = list(tooltipStart = "Click and drag to draw circle.") + circlemarker = list(tooltipStart = "Click and drag to draw circle."), + simpleshape = list(tooltipEnd = "Release mouse to finish drawing.") ) } \arguments{ @@ -28,6 +29,8 @@ handlersOptions( \item{marker}{List of options for marker tooltips.} \item{circlemarker}{List of options for circlemarker tooltips.} + +\item{simpleshape}{List of options for simpleshape tooltips.} } \description{ Customize tooltips for \code{\link{addDrawToolbar}}