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.
add_draw_control(
map,
id = "draw_control",
position = "top-right",
modes = c("polygon"),
active_colour = "#04AAC1",
inactive_colour = "#04AAC1",
mode_labels = list(),
panel_id = NULL,
section_title = NULL,
group_id = NULL
)The map or map proxy object for chaining.
The map or map proxy object.
The ID for the draw control.
The position of the draw control on the map. Default is "top-right".
Options are "top-left", "top-right", "bottom-left", "bottom-right".
A vector of modes to enable in the draw control. Default is c("polygon").
Options include "polygon", "delete", "line", and "point".
The colour for the drawn shapes. Default is "#04AAC1".
The colour for the inactive shapes. Default is "#04AAC1".
A named list of labels for each mode.
For example, list(polygon = "Draw Polygon", delete = "Delete Shape").
ID of control panel to add to (optional).
Section title when added to a control panel.
Optional group ID for grouping controls within a panel.
For a more in-depth example see the Draw control article.
get_drawn_shape() to retrieve the drawn shape as an sf object in Shiny.