Skip to content

draw

Stable

Lets the user draw and edit shapes on the map, such as geofences, from a toolbar of its own or the application's buttons, sends them to the LiveView as GeoJSON, and shows the shapes the LiveView gives it.

Generated from the component's definition in the library, so it always matches the version this demo runs.

Attribute Type Default Description
id required string — Unique identifier of the drawing, also the start of the ids of the sources and layers Terra Draw adds to the map (see On the map in the module docs). Read when the component mounts
map_id required string — ID of the map to draw on. Read when the component mounts
mode any — a mode of modes, or nil (the default) for none
modes list [:polygon, :rectangle, :circle, :line, :point, :select] the modes to set up
features list [] the shapes to show and edit: GeoJSON Features, each with an id of the LiveView's
fill_color string nil the fill colour of polygons, rectangles and circles
fill_opacity any nil their fill opacity, from 0 to 1
outline_color string nil the colour of their outlines, and of lines
outline_width any nil the width of their outlines, and of lines, in pixels
point_color string nil the colour of points
point_radius any nil the radius of points, in pixels
selected_color string nil the colour of the selected shape
handle_color string nil the colour of the handles the user drags
toolbar any nil the corner of the map for a toolbar: "top-left", "top-right", ...
toolbar_labels map %{} the labels of the toolbar's buttons, by mode or :cancel
events any [] a list of event names, or :all