|
| 1 | +--- |
| 2 | +title: Drawing tools interaction types and keyboard shortcuts in Azure Maps| Microsoft Docs |
| 3 | +description: How to draw and edit shapes using a mouse, touch screen, or keyboard in the Azure Maps Web SDK |
| 4 | +author: rbrundritt |
| 5 | +ms.author: richbrun |
| 6 | +ms.date: 12/05/2019 |
| 7 | +ms.topic: conceptual |
| 8 | +ms.service: azure-maps |
| 9 | +services: azure-mapss |
| 10 | +manager: cpendleton |
| 11 | +--- |
| 12 | + |
| 13 | +# Interaction types and keyboard shortcuts in the drawing tools module |
| 14 | + |
| 15 | +This article outlines all the different ways to draw and edit shapes on a map using a mouse, a touch screen, or keyboard shortcuts. |
| 16 | + |
| 17 | +The drawing manager supports three different ways of interacting with the map to draw shapes. |
| 18 | + |
| 19 | +* `click` - Coordinates are added when the mouse or touch is clicked. |
| 20 | +* `freehand ` - Coordinates are added when the mouse or touch is dragged on the map. |
| 21 | +* `hybrid` - Coordinates are added when the mouse or touch is clicked or dragged. |
| 22 | + |
| 23 | +## How to draw shapes |
| 24 | + |
| 25 | +The following outlines all the different ways that shapes can be drawn on the map. Before any shape can be drawn, the `drawingMode` option of the drawing manager needs to be set to a supported drawing setting. This can be done programmatically, or by pressing a one of the drawing buttons on the toolbar. The drawing mode stays enabled, even after a shape has been drawn, making it easy to draw additional shapes of the same type. The drawing mode can be put into an idle state programmatically, or by clicking the current drawing modes button on the toolbar. |
| 26 | + |
| 27 | +### How to draw a point |
| 28 | + |
| 29 | +When the drawing manager is in `draw-point` drawing mode, the following actions can be done to draw points on the map. These methods work with all interaction modes. |
| 30 | + |
| 31 | +**Start drawing** |
| 32 | + - Click the left mouse button or touch the map to add a point to the map. |
| 33 | + - If the mouse is over the map, press the `F` key, and a point will be added using the coordinate of where the mouse pointer is. This will provide a higher accuracy method of adding a point to the map as there will be less movement on the mouse due to the pressing motion of the left mouse button. |
| 34 | + - Keep clicking, touching, or pressing `F` to add more points to the map. |
| 35 | + |
| 36 | +**Finish drawing** |
| 37 | + - Click on any button in the drawing toolbar. |
| 38 | + - Programmatically set the drawing mode. |
| 39 | + - Press the `C` key. |
| 40 | + |
| 41 | +**Cancel drawing** |
| 42 | + - Press the `Escape` key. |
| 43 | + |
| 44 | +### How to draw a line |
| 45 | + |
| 46 | +When the drawing manager is in `draw-line` mode, the following actions can be done to draw points on the map depending on what the interaction mode is set to. |
| 47 | + |
| 48 | +**Start drawing** |
| 49 | + - Click mode |
| 50 | + * Click the left mouse button or touch the map to add each point of a line on the map. A coordinate is added to the line for each click/touch. |
| 51 | + * If the mouse is over the map, press the `F` key, and a point will be added using the coordinate of where the mouse pointer is. This will provide a higher accuracy method of adding a point to the map as there will be less movement on the mouse due to the pressing motion of the left mouse button. |
| 52 | + * Keep clicking until all the desired points have been added to the line. |
| 53 | + - Freehand mode |
| 54 | + * Press down the left mouse button or touch-down on the map and drag the mouse or touch point around. Coordinates are added to the line as the mouse or touch point moves around the map. As soon as the mouse or touch-up event is triggered, the drawing is completed. The frequency at which coordinates are added is defined by the drawing managers `freehandInterval` option. |
| 55 | + - Hybrid mode |
| 56 | + * Alternate between click and freehand methods as desired while drawing a single line. For example, click a few points, then hold and drag the mouse to add a bunch of points, then click a few more. |
| 57 | + |
| 58 | +**Finish drawing** |
| 59 | + - Hybrid/Click mode |
| 60 | + * Double-click the map at the last point. |
| 61 | + * Click on any button in the drawing toolbar. |
| 62 | + * Programmatically set the drawing mode. |
| 63 | + - Freehand mode |
| 64 | + * Release the mouse button or touch point. |
| 65 | + - Press the `C` key. |
| 66 | + |
| 67 | +**Cancel drawing** |
| 68 | + - Press the `Escape` key. |
| 69 | + |
| 70 | +### How to draw a polygon |
| 71 | + |
| 72 | +When the drawing manager is in `draw-polygon` mode, the following actions can be done to draw points on the map depending on what the interaction mode is set to. |
| 73 | + |
| 74 | +**Start drawing** |
| 75 | + - Click mode |
| 76 | + * Click the left mouse button or touch the map to add each point of a polygon on the map. A coordinate is added to the polygon for each click/touch. |
| 77 | + * If the mouse is over the map, press the `F` key, and a point will be added using the coordinate of where the mouse pointer is. This will provide a higher accuracy method of adding a point to the map as there will be less movement on the mouse due to the pressing motion of the left mouse button. |
| 78 | + * Keep clicking until all the desired points have been added to the polygon. |
| 79 | + - Freehand mode |
| 80 | + * Press down the left mouse button or touch-down on the map and drag the mouse or touch point around. Coordinates are added to the polygon as the mouse or touch point moves around the map. As soon as the mouse or touch-up event is triggered, the drawing is completed. Note that the frequency at which coordinates are added is defined by the drawing managers `freehandInterval` option. |
| 81 | + - Hybrid mode |
| 82 | + * Alternate between click and freehand methods as desired while drawing a single polygon. For example, click a few points, then hold and drag the mouse to add a bunch of points, then click a few more. |
| 83 | + |
| 84 | +**Finish drawing** |
| 85 | + - Hybrid/Click mode |
| 86 | + * Double-click the map at the last point. |
| 87 | + * Click on the first point in the polygon. |
| 88 | + * Click on any button in the drawing toolbar. |
| 89 | + * Programmatically set the drawing mode. |
| 90 | + - Freehand mode |
| 91 | + * Release the mouse button or touch point. |
| 92 | + - Press the `C` key. |
| 93 | + |
| 94 | +**Cancel drawing** |
| 95 | + - Press the `Escape` key. |
| 96 | + |
| 97 | +### How to draw a rectangle |
| 98 | + |
| 99 | +When the drawing manager is in `draw-rectangle` mode, the following actions can be done to draw points on the map depending on what the interaction mode is set to. The generated shape will follow the [extended GeoJSON specification for rectangles](extend-geojson.md#rectangle). |
| 100 | + |
| 101 | +**Start drawing** |
| 102 | + - Press down the left mouse button or touch-down on the map to add the first corner of the rectangle and drag to create the rectangle. |
| 103 | + |
| 104 | +**Finish drawing** |
| 105 | + - Release the mouse button or touch point. |
| 106 | + - Programmatically set the drawing mode. |
| 107 | + - Press the `C` key. |
| 108 | + |
| 109 | +**Cancel drawing** |
| 110 | + - Press the `Escape` key. |
| 111 | + |
| 112 | +### How to draw a circle |
| 113 | + |
| 114 | +When the drawing manager is in `draw-circle` mode, the following actions can be done to draw points on the map depending on what the interaction mode is set to. The generated shape will follow the [extended GeoJSON specification for circles](extend-geojson.md#circle). |
| 115 | + |
| 116 | +**Start drawing** |
| 117 | + - Press down the left mouse button or touch-down on the map to add the center of the circle and drag give the circles a radius. |
| 118 | + |
| 119 | +**Finish drawing** |
| 120 | + - Release the mouse button or touch point. |
| 121 | + - Programmatically set the drawing mode. |
| 122 | + - Press the `C` key. |
| 123 | + |
| 124 | +**Cancel drawing** |
| 125 | + - Press the `Escape` key. |
| 126 | + |
| 127 | +## Keyboard shortcuts |
| 128 | + |
| 129 | +The drawing tools support keyboard shortcuts that make it easier to draw and edit shapes on the map. These keyboard shortcuts are functional when the map has focus. |
| 130 | + |
| 131 | +| Key | Action | |
| 132 | +|----------|-----------------------------------| |
| 133 | +| `C` | Completes any drawing that is in progress and sets the drawing mode to idle. Focus will move to top-level map element. | |
| 134 | +| `Escape` | Cancels any drawing that is in progress and sets the drawing mode to idle. Focus will move to top-level map element. | |
| 135 | +| `F` | Adds a coordinate to a point, line, or polygon if the mouse is over the map. Equivalent action of clicking the map when in click or hybrid mode. This shortcut allows for more precise and faster drawings as you can use one hand to position the mouse and other to press the button without the mouse moving from the press gesture. | |
| 136 | + |
| 137 | +## Next steps |
| 138 | + |
| 139 | +Learn more about the classes in the drawing tools module: |
| 140 | + |
| 141 | +> [!div class="nextstepaction"] |
| 142 | +> [Drawing manager](https://docs.microsoft.com/javascript/api/azure-maps-drawing-tools/atlas.drawing.drawingmanager?view=azure-node-latest) |
| 143 | +
|
| 144 | +> [!div class="nextstepaction"] |
| 145 | +> [Drawing toolbar](https://docs.microsoft.com/javascript/api/azure-maps-drawing-tools/atlas.control.drawingtoolbar?view=azure-node-latest) |
0 commit comments