Skip to content

Commit ac8d4c6

Browse files
authored
Merge pull request #109500 from stevemunk/drawing-tools-events-CodePen
Removing the CodePen samples from the Drawing tools events article
2 parents 579b1de + 5f4abf7 commit ac8d4c6

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

articles/azure-maps/drawing-tools-events.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Drawing tool events | Microsoft Azure Maps
33
description: This article demonstrates how to add a drawing toolbar to a map using Microsoft Azure Maps Web SDK
4-
author: brendansco
5-
ms.author: Brendanc
6-
ms.date: 12/05/2019
4+
author: dubiety
5+
ms.author: yuchungchen
6+
ms.date: 05/23/2023
77
ms.topic: conceptual
88
ms.service: azure-maps
99
services: azure-maps
@@ -22,16 +22,21 @@ When using drawing tools on a map, it's useful to react to certain events as the
2222
| `drawingmodechanged` | Fired when the drawing mode has changed. The new drawing mode is passed into the event handler. |
2323
| `drawingstarted` | Fired when the user starts drawing a shape or puts a shape into edit mode. |
2424

25-
The following code shows how the events in the Drawing Tools module work. Draw shapes on the map and watch as the events fire.
25+
For a complete working sample of how to display data from a vector tile source on the map, see [Drawing tool events] in the [Azure Maps Samples]. In this sample you can draw shapes on the map and watch as the events fire.
2626

27+
The following image shows a screenshot of the complete working sample that demonstrates how the events in the Drawing Tools module work.
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.":::
30+
31+
<!------------------------------------------------------------------
2732
<br/>
2833
2934
<iframe height="500" scrolling="no" title="Drawing tools events" src="https://codepen.io/azuremaps/embed/dyPMRWo?height=500&theme-id=default&default-tab=js,result&editable=true" frameborder='no' loading="lazy" allowtransparency="true" allowfullscreen="true">
3035
See the Pen <a href='https://codepen.io/azuremaps/pen/dyPMRWo'>Drawing tools events</a> by Azure Maps
3136
(<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
3237
</iframe>
3338
34-
<br/>
39+
-------------------------------------------------------------------->
3540

3641
## Examples
3742

@@ -41,40 +46,50 @@ Let's see some common scenarios that use the drawing tools events.
4146

4247
This code demonstrates how to monitor an event of a user drawing shapes. For this example, the code monitors shapes of polygons, rectangles, and circles. Then, it determines which data points on the map are within the drawn area. The `drawingcomplete` event is used to trigger the select logic. In the select logic, the code loops through all the data points on the map. It checks if there's an intersection of the point and the area of the drawn shape. This example makes use of the open-source [Turf.js](https://turfjs.org/) library to perform a spatial intersection calculation.
4348

49+
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].
50+
51+
:::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.":::
52+
53+
<!-------------------------------------------------------------------
4454
<br/>
4555
4656
<iframe height="500" scrolling="no" title="Select data in drawn polygon area" src="https://codepen.io/azuremaps/embed/XWJdeja?height=500&theme-id=default&default-tab=result" frameborder='no' loading="lazy" allowtransparency="true" allowfullscreen="true">
4757
See the Pen <a href='https://codepen.io/azuremaps/pen/XWJdeja'>Select data in drawn polygon area</a> by Azure Maps
4858
(<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
4959
</iframe>
50-
51-
<br/>
60+
---------------------------------------------------------------->
5261

5362
### Draw and search in polygon area
5463

5564
This code searches for points of interests inside the area of a shape after the user finished drawing the shape. You can modify and execute the code by clicking 'Edit on Code pen' on the top-right corner of the frame. 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.
5665

66+
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].
67+
68+
:::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.":::
69+
70+
<!-------------------------------------------------------------------
5771
<br/>
5872
5973
<iframe height="500" scrolling="no" title="Draw and search in polygon area" src="https://codepen.io/azuremaps/embed/eYmZGNv?height=500&theme-id=default&default-tab=js,result&editable=true" frameborder='no' loading="lazy" allowtransparency="true" allowfullscreen="true">
6074
See the Pen <a href='https://codepen.io/azuremaps/pen/eYmZGNv'>Draw and search in polygon area</a> by Azure Maps
6175
(<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
6276
</iframe>
63-
64-
<br/>
77+
---------------------------------------------------------------->
6578

6679
### Create a measuring tool
6780

6881
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.
6982

70-
<br/>
83+
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].
7184

85+
:::image type="content" source="./media/drawing-tools-events/create-a-measuring-tool.png" alt-text="Screenshot showing a map displaying the measuring tool sample.":::
86+
87+
<!-------------------------------------------------------------------
7288
<iframe height="500" scrolling="no" title="Measuring tool" src="https://codepen.io/azuremaps/embed/RwNaZXe?height=500&theme-id=default&default-tab=js,result&editable=true" frameborder='no' loading="lazy" allowtransparency="true" allowfullscreen="true">
7389
See the Pen <a href='https://codepen.io/azuremaps/pen/RwNaZXe'>Measuring tool</a> by Azure Maps
7490
(<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
7591
</iframe>
76-
77-
<br/>
92+
---------------------------------------------------------------->
7893

7994
## Next steps
8095

@@ -95,3 +110,9 @@ Check out more code samples:
95110

96111
> [!div class="nextstepaction"]
97112
> [Code sample page](https://aka.ms/AzureMapsSamples)
113+
114+
[Azure Maps Samples]:https://samples.azuremaps.com
115+
[Drawing tool events]: https://samples.azuremaps.com/?search=Drawing%20tool&sample=drawing-tools-events
116+
[Select data in drawn polygon area]:https://samples.azuremaps.com/?search=Drawing%20tool&sample=select-data-in-drawn-polygon-area
117+
[Draw and search polygon area]: https://samples.azuremaps.com/?search=Drawing%20tool&sample=draw-and-search-polygon-area
118+
[Create a measuring tool]: https://samples.azuremaps.com/?search=Drawing%20tool&sample=create-a-measuring-tool
494 KB
Loading
951 KB
Loading
422 KB
Loading
617 KB
Loading

0 commit comments

Comments
 (0)