You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: This article demonstrates how to add a drawing toolbar to a map using Microsoft Azure Maps Web SDK
4
4
author: sinnypan
5
5
ms.author: sipa
6
-
ms.date: 05/23/2023
6
+
ms.date: 09/03/2024
7
7
ms.topic: how-to
8
8
ms.service: azure-maps
9
9
ms.subservice: web-sdk
@@ -15,18 +15,18 @@ When using drawing tools on a map, it's useful to react to certain events as the
15
15
16
16
| Event | Description |
17
17
|-------|-------------|
18
-
|`drawingchanged`| Fired when any coordinate in a shape has been added or changed. |
18
+
|`drawingchanged`| Fired when any coordinate in a shape is added or changed. |
19
19
|`drawingchanging`| Fired when any preview coordinate for a shape is being displayed. For example, this event fires multiple times as a coordinate is dragged. |
20
-
|`drawingcomplete`| Fired when a shape has finished being drawn or taken out of edit mode. |
20
+
|`drawingcomplete`| Fired when a shape completes drawing or is taken out of edit mode. |
21
21
|`drawingerased`| Fired when a shape is erased from the drawing manager when in `erase-geometry` mode. |
22
-
|`drawingmodechanged`| Fired when the drawing mode has changed. The new drawing mode is passed into the event handler. |
22
+
|`drawingmodechanged`| Fired when the drawing mode changes. The new drawing mode is passed into the event handler. |
23
23
|`drawingstarted`| Fired when the user starts drawing a shape or puts a shape into edit mode. |
24
24
25
-
For a complete working sample of how to display data from a vector tile source on the map, see [Drawing tools events] in the [Azure Maps Samples]. In this sample you can draw shapes on the map and watch as the events fire. For the source code for this sample, see [Drawing tools events sample code].
25
+
For a complete working sample of how to display data from a vector tile source on the map, see [Drawing tools events] in the [Azure Maps Samples]. This sample enables you to draw shapes on the map and watch as the events fire. For the source code for this sample, see [Drawing tools events sample code].
26
26
27
27
The following image shows a screenshot of the complete working sample that demonstrates how the events in the Drawing Tools module work.
28
28
29
-
:::image type="content" source="./media/drawing-tools-events/drawing-tools-events.png" alt-text="Screenshot showing a map displaying data from a vector tile source.":::
29
+
:::image type="content" source="./media/drawing-tools-events/drawing-tools-events.png" lightbox="./media/drawing-tools-events/drawing-tools-events.png" alt-text="Screenshot showing a map displaying data from a vector tile source.":::
30
30
31
31
## Examples
32
32
@@ -38,23 +38,23 @@ This code demonstrates how to monitor an event of a user drawing shapes. For thi
38
38
39
39
For a complete working sample of how to use the drawing tools to draw polygon areas on the map with points within them that can be selected, see [Select data in drawn polygon area] in the [Azure Maps Samples]. For the source code for this sample, see [Select data in drawn polygon area sample code].
40
40
41
-
:::image type="content" source="./media/drawing-tools-events/select-data-in-drawn-polygon-area.png" alt-text="Screenshot showing a map displaying points within polygon areas.":::
41
+
:::image type="content" source="./media/drawing-tools-events/select-data-in-drawn-polygon-area.png" lightbox="./media/drawing-tools-events/select-data-in-drawn-polygon-area.png" alt-text="Screenshot showing a map displaying points within polygon areas.":::
42
42
43
43
### Draw and search in polygon area
44
44
45
45
This code searches for points of interests inside the area of a shape after the user finished drawing the shape. The `drawingcomplete` event is used to trigger the search logic. If the user draws a rectangle or polygon, a search inside geometry is performed. If a circle is drawn, the radius and center position is used to perform a point of interest search. The `drawingmodechanged` event is used to determine when the user switches to the drawing mode, and this event clears the drawing canvas.
46
46
47
47
For a complete working sample of how to use the drawing tools to search for points of interests within drawn areas, see [Draw and search polygon area] in the [Azure Maps Samples]. For the source code for this sample, see [Draw and search polygon area sample code].
48
48
49
-
:::image type="content" source="./media/drawing-tools-events/draw-and-search-polygon-area.png" alt-text="Screenshot showing a map displaying the Draw and search in polygon area sample.":::
49
+
:::image type="content" source="./media/drawing-tools-events/draw-and-search-polygon-area.png" lightbox="./media/drawing-tools-events/draw-and-search-polygon-area.png" alt-text="Screenshot showing a map displaying the Draw and search in polygon area sample.":::
50
50
51
51
### Create a measuring tool
52
52
53
-
The following code shows how the drawing events can be used to create a measuring tool. The `drawingchanging` is used to monitor the shape, as it's being drawn. As the user moves the mouse, the dimensions of the shape are calculated. The `drawingcomplete` event is used to do a final calculation on the shape after it has been drawn. The `drawingmodechanged` event is used to determine when the user is switching into a drawing mode. Also, the `drawingmodechanged` event clears the drawing canvas and clears old measurement information.
53
+
The following code shows how the drawing events can be used to create a measuring tool. The `drawingchanging` is used to monitor the shape, as it's being drawn. As the user moves the mouse, the dimensions of the shape are calculated. The `drawingcomplete` event is used to do a final calculation on the shape after drawing completes. The `drawingmodechanged` event is used to determine when the user is switching into a drawing mode. Also, the `drawingmodechanged` event clears the drawing canvas and clears old measurement information.
54
54
55
55
For a complete working sample of how to use the drawing tools to measure distances and areas, see [Create a measuring tool] in the [Azure Maps Samples]. For the source code for this sample, see [Create a measuring tool sample code].
56
56
57
-
:::image type="content" source="./media/drawing-tools-events/create-a-measuring-tool.png" alt-text="Screenshot showing a map displaying the measuring tool sample.":::
57
+
:::image type="content" source="./media/drawing-tools-events/create-a-measuring-tool.png" lightbox="./media/drawing-tools-events/create-a-measuring-tool.png" alt-text="Screenshot showing a map displaying the measuring tool sample.":::
0 commit comments