<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Draw toolbar events in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447739#M41365</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Agreed since you only need to quickly check if a polygon exists, no need to run it long.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 May 2015 13:53:09 GMT</pubDate>
    <dc:creator>TimWitt2</dc:creator>
    <dc:date>2015-05-20T13:53:09Z</dc:date>
    <item>
      <title>Draw toolbar events</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447732#M41358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the Draw toolbar to allow the user to draw a polygon on the map.&amp;nbsp; I want to identify when the user has started a new polygon, but the toolbar only fires two events: draw-complete and draw-end - there doesn't seem to be a draw-start event.&amp;nbsp; However I know there must be something behind the scenes because the default tooltip is "Click to start drawing" before the polygon has been started, "Click to continue drawing" once the first point is set and "Double-click to complete" for all subsequent points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas how I can grab hold of the event fired when the first point is clicked?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sarah Noakes&lt;/P&gt;&lt;P&gt;Cornwall Council.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 13:16:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447732#M41358</guid>
      <dc:creator>SarahNoakes1</dc:creator>
      <dc:date>2015-05-20T13:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Draw toolbar events</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447733#M41359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sarah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you tell us what you want to do once the user starts drawing? Maybe there is a different way?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 13:24:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447733#M41359</guid>
      <dc:creator>TimWitt2</dc:creator>
      <dc:date>2015-05-20T13:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Draw toolbar events</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447734#M41360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tim,&lt;/P&gt;&lt;P&gt;If there is already a polygon in the graphics layer I want to remove it when the user starts to draw a new one.&amp;nbsp; The only workaround I can think of at the moment is to remove the existing polygon (if there is one) when the draw-complete event fires, but I think that looks a bit clunky.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Sarah.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 13:29:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447734#M41360</guid>
      <dc:creator>SarahNoakes1</dc:creator>
      <dc:date>2015-05-20T13:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Draw toolbar events</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447735#M41361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But if you really need it. Here is what I did in my draw tool: &lt;A href="https://community.esri.com/migration-blogpost/1200"&gt;Javascript API - Advanced Draw widget&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the user activates the draw tool i start a map.on("click") event called draw_MapOnClick.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when the user first clicks on the map, the map on click event does something and on draw end I remove the draw_MapOnClick event.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this makes sense!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 13:31:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447735#M41361</guid>
      <dc:creator>TimWitt2</dc:creator>
      <dc:date>2015-05-20T13:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Draw toolbar events</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447736#M41362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;EDIT: I see Tim has already covered this but I would use mouse-down and then remove it immediately to capture the first user interaction only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sarah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Most developers just add a mouse-down event listener to the map when the draw is activated and then immediately remove it once it has been fired. This allows you to catch the first mouse down event whether it is a drag for a rectangle, circle, or a standard click for a point.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 13:33:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447736#M41362</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-05-20T13:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Draw toolbar events</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447737#M41363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sarah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is what I meant, once the draw is active and the person clicked the map, check if your tool is using a polygon. If it does, remove the other polygon and disconnect the map click event.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 13:35:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447737#M41363</guid>
      <dc:creator>TimWitt2</dc:creator>
      <dc:date>2015-05-20T13:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Draw toolbar events</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447738#M41364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use the button click event to clear the map's graphic before the new feature is drawn, using something like this (from &lt;A href="https://developers.arcgis.com/javascript/jssamples/graphics_add.html" title="https://developers.arcgis.com/javascript/jssamples/graphics_add.html" rel="nofollow noopener noreferrer" target="_blank"&gt;Add graphics to a map | ArcGIS API for JavaScript&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;on(dom.byId("info"), "click", function(evt) {
&amp;nbsp; if ( evt.target.id === "info" ) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; return;
&amp;nbsp; }
&amp;nbsp; map.graphics.clear();
&amp;nbsp; var tool = evt.target.id.toLowerCase();
&amp;nbsp; map.disableMapNavigation();
&amp;nbsp; tb.activate(tool);
});&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:00:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447738#M41364</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-11T20:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: Draw toolbar events</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447739#M41365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Agreed since you only need to quickly check if a polygon exists, no need to run it long.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 13:53:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447739#M41365</guid>
      <dc:creator>TimWitt2</dc:creator>
      <dc:date>2015-05-20T13:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Draw toolbar events</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447740#M41366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks everyone - got it working with a couple of lines of code.&amp;nbsp; I still think a draw-start event would be a sensible addition though ;o)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 14:07:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447740#M41366</guid>
      <dc:creator>SarahNoakes1</dc:creator>
      <dc:date>2015-05-20T14:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Draw toolbar events</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447741#M41367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah that's true. It would make it a lot easier to do some of the things, like adding measurements, with less code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 14:11:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447741#M41367</guid>
      <dc:creator>TimWitt2</dc:creator>
      <dc:date>2015-05-20T14:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Draw toolbar events</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447742#M41368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sarah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After trying a few different methods, the best way I've been able to implement what you're describing without an onDrawBegin event is to use a dojo/on.pausable() event that goes off on the map.onmousedown event, pause it, and only unpause it when the draw-end event occurs.&amp;nbsp; Here's how it would look:&lt;/P&gt;&lt;P&gt;require([..., "esri/map", "dojo/on", "esri/toolbars/draw", ...], function (..., Map, dojoOn, DrawToolbar, ...) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; ...&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; var map = new Map("mapdiv", {...});&lt;/P&gt;&lt;P&gt;&amp;nbsp; var drawtoolbar = new DrawToolbar(map, {...});&lt;/P&gt;&lt;P&gt;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp; var clearGraphicsHandler = dojoOn.pausable(map, "mousedown", function () {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7ed529;"&gt; // clear the map graphics layer&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.graphics.clear();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7ed529;"&gt;// test if you can pause the clearGraphicsHandler after the event is called.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (clearGraphicsHandler &amp;amp;amp; typeof clearGraphicsHandler.pause === "function") {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clearGraphicsHandler.pause();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: #7ed529;"&gt;// pause it for now&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; clearGraphicsHandler.pause();&lt;/P&gt;&lt;P&gt;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp; dojoOn(drawtoolbar, "draw-end", function (evt) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7ed529;"&gt;// do something to add the drawing on the map.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7ed529;"&gt;// resume the clearGraphicsHandler when you touch the map to draw again.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clearGraphicsHandler.resume();&lt;/P&gt;&lt;P&gt;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: #7ed529;"&gt;// remember if you switch away from this tool, and want to preserve the current graphic, be sure to call clearGraphicsHandler.pause();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;}); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's more things you could do to make this more robust. Hopefully, this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 15:05:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/draw-toolbar-events/m-p/447742#M41368</guid>
      <dc:creator>KenDoman</dc:creator>
      <dc:date>2015-05-20T15:05:54Z</dc:date>
    </item>
  </channel>
</rss>

