Description Usage Arguments Examples
Adds a Toolbar to draw shapes/points on the map.
Removes the draw toolbar
1 2 3 4 5 6 7 8 9 10 11 | addDrawToolbar(map, targetLayerId = NULL, targetGroup = NULL,
position = c("topleft", "topright", "bottomleft", "bottomright"),
polylineOptions = drawPolylineOptions(),
polygonOptions = drawPolygonOptions(),
circleOptions = drawCircleOptions(),
rectangleOptions = drawRectangleOptions(),
markerOptions = drawMarkerOptions(),
circleMarkerOptions = drawCircleMarkerOptions(), editOptions = FALSE,
singleFeature = FALSE)
removeDrawToolbar(map, clearFeatures = FALSE)
|
map |
The map widget. |
targetLayerId |
An optional layerId of a GeoJSON/TopoJSON layer whose features need to be editable. Used for adding a GeoJSON/TopoJSON layer and then editing the features using the draw plugin. |
targetGroup |
An optional group name of a Feature Group whose features need to be editable. Used for adding shapes(markers, lines, polygons) and then editing them using the draw plugin. You can either set layerId or group or none but not both. |
position |
The position where the toolbar should appear. |
polylineOptions |
See |
polygonOptions |
See |
circleOptions |
See |
rectangleOptions |
See |
markerOptions |
See |
circleMarkerOptions |
See |
editOptions |
By default editing is disable. To enable editing pass |
singleFeature |
When set to TRUE, only one feature can be drawn at a time, the previous ones being removed. |
clearFeatures |
whether to clear the map of drawn features. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | leaflet() %>%
setView(0, 0, 2) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addDrawToolbar(
targetGroup = "draw",
editOptions = editToolbarOptions(
selectedPathOptions = selectedPathOptions()
)
) %>%
addLayersControl(
overlayGroups = c("draw"),
options = layersControlOptions(collapsed = FALSE)
) %>%
addStyleEditor()
## for more examples see
# browseURL(system.file("examples/draw.R", package = "leaflet.extras"))
|
Loading required package: leaflet
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.