The draw control allows users to draw shapes (polygons, lines, points) on the map.
The drawn shapes can be styled and managed through the control options.
Information about the drawn shapes can be retrieved in Shiny using the
input$map_shape_created (where map is the ID of the map) reactive value.
Arguments
- map
The map or map proxy object.
- id
The ID for the draw control.
- position
The position of the draw control on the map. Default is
"top-right". Options are "top-left", "top-right", "bottom-left", "bottom-right".- modes
A vector of modes to enable in the draw control. Default is
c("polygon"). Options include "polygon", "delete", "line", and "point".- active_colour
The colour for the drawn shapes. Default is
"#04AAC1".- inactive_colour
The colour for the inactive shapes. Default is
"#04AAC1".- mode_labels
A named list of labels for each mode. For example,
list(polygon = "Draw Polygon", delete = "Delete Shape").- panel_id
ID of control panel to add to (optional).
- section_title
Section title when added to a control panel.
- group_id
Optional group ID for grouping controls within a panel.
Details
For a more in-depth example see the Draw control article.
See also
get_drawn_shape() to retrieve the drawn shape as an sf object in Shiny.
Examples
map() |>
add_draw_control()
