Skip to main content

DrawToolbar

The draw toolbar: a switch for what to draw, the name and measures of the shape under way or selected, buttons to add a point at the map centre, undo, redo, cancel or delete, open the list of shapes and finish, and a group of controls for the selected shape. It sits in a landmark named "Drawing", so it is inside a landmark wherever the host places it.

This is a function exported by @mapcairn/map, checked against version 0.2.0.

Signature​

import { DrawToolbar } from "@mapcairn/map";

function DrawToolbar(input: DrawToolbarProps): JSX.Element;

Description​

On mount focus moves to the chosen shape type, because the person has just chosen Draw and the next thing to do is here. The bottom-centre slot it sits in is what the slots below it ride above. The toolbar registers its Shapes button as a focus target, so closing the sheet over a drawing puts focus back on it.

Parameters​

  • { draw, onDone, onOpenShapes }
  • input (DrawToolbarProps)

Returns​

JSX.Element

Remarks​

Every pointer action has a button: Add point at map centre places a point (or moves the selected one), Previous and Next point select, the group moves, adds and removes points, and the circle group sets the radius. The arrow keys move the selected point from the map, or while focus is in the selected shape's group, and Escape and the undo keys work from anywhere in the toolbar. The primary button is Finish while a shape is being drawn and Done otherwise, in one element, so focus stays put when it changes. Cancel and Delete are one button for the same reason. The button keeps the width of the longer label and its check mark in both states, so the row does not wrap, and the toolbar does not change height, when the label changes.

See also​

Source: packages/map/src/tools/DrawToolbar/DrawToolbar.tsx:207