<?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: Pause or Resume Draw or DrawAction, or Add Vertices to Draw or DrawAction Programmatically in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pause-or-resume-draw-or-drawaction-or-add-vertices/m-p/1167153#M77113</link>
    <description>&lt;P&gt;I have a fix for that double-click behavior&amp;nbsp;&lt;EM&gt;for polylines&lt;/EM&gt;. Once I get it working for polygons too, I'll share what I did. Thanks again for the head start!&lt;/P&gt;</description>
    <pubDate>Fri, 22 Apr 2022 18:51:20 GMT</pubDate>
    <dc:creator>GaryLSheppardJr</dc:creator>
    <dc:date>2022-04-22T18:51:20Z</dc:date>
    <item>
      <title>Pause or Resume Draw or DrawAction, or Add Vertices to Draw or DrawAction Programmatically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pause-or-resume-draw-or-drawaction-or-add-vertices/m-p/1165262#M77039</link>
      <description>&lt;P&gt;I'm using the &lt;FONT face="courier new,courier"&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-Draw.html" target="_blank" rel="noopener"&gt;Draw&lt;/A&gt;&lt;/FONT&gt; class to let the user draw different kinds of graphics on the map. The &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/draw-line/" target="_blank" rel="noopener"&gt;Draw polyline sample&lt;/A&gt; works really well. Now I would like to let the user pause drawing and then resume the in-progress drawing. Is this possible using the &lt;FONT face="courier new,courier"&gt;Draw&lt;/FONT&gt; class?&lt;/P&gt;&lt;P&gt;I don't see anything on &lt;FONT face="courier new,courier"&gt;Draw&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;DrawAction&lt;/FONT&gt; that would let me pause and resume, which would be exactly what I want. What about cancelling the drawing, saving the vertices in memory, and then adding those vertices to a new &lt;FONT face="courier new,courier"&gt;Draw&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;DrawAction&lt;/FONT&gt;? Is that possible, and if so, how is it done?&lt;/P&gt;&lt;P&gt;This is similar to &lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/can-i-set-starting-geometry-for-sketchviewmodel/m-p/1107029" target="_blank" rel="noopener"&gt;my previous question&lt;/A&gt; about doing something similar with &lt;FONT face="courier new,courier"&gt;SketchViewModel&lt;/FONT&gt;. This new question is about &lt;FONT face="courier new,courier"&gt;Draw&lt;/FONT&gt; as opposed to &lt;FONT face="courier new,courier"&gt;SketchViewModel&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 18:01:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pause-or-resume-draw-or-drawaction-or-add-vertices/m-p/1165262#M77039</guid>
      <dc:creator>GaryLSheppardJr</dc:creator>
      <dc:date>2022-04-18T18:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Pause or Resume Draw or DrawAction, or Add Vertices to Draw or DrawAction Programmatically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pause-or-resume-draw-or-drawaction-or-add-vertices/m-p/1166481#M77077</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;What about cancelling the drawing, saving the vertices in memory, and then adding those vertices to a new &lt;FONT face="courier new,courier"&gt;Draw&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;DrawAction&lt;/FONT&gt;? Is that possible, and if so, how is it done?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I think that, using this approach, you will be able to achieve what you're going for. The first part of this scenario — starting a drawing operation and then "pausing" it — will be fairly straightforward. You will start the &lt;FONT face="andale mono,times"&gt;DrawAction&lt;/FONT&gt; as normal. The UI for the "pause" action will be up to you, but as far as JS API components are concerned, you will simply call the &lt;FONT face="andale mono,times"&gt;complete()&lt;/FONT&gt; method of either the &lt;FONT face="andale mono,times"&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-Draw.html#complete" target="_blank" rel="noopener"&gt;Draw&lt;/A&gt;&lt;/FONT&gt; or the &lt;FONT face="andale mono,times"&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-PolylineDrawAction.html#complete" target="_blank" rel="noopener"&gt;DrawAction&lt;/A&gt;&lt;/FONT&gt;. Note that, unlike in the higher-level context of &lt;FONT face="andale mono,times"&gt;SketchViewModel&lt;/FONT&gt;, there is not a specific method to "cancel" the operation, but that's only because, in the lower-level context of &lt;FONT face="andale mono,times"&gt;Draw&lt;/FONT&gt;, where the API components are not adding any graphics to the view for you, there wouldn't really be a difference between "completing" and "canceling."&lt;/P&gt;&lt;P&gt;The second part — "resuming" the drawing operation — is less straightforward, but still able to be done cleanly and without having to resort to any convoluted or hacky code. I have made a &lt;A href="https://codepen.io/tristan-morrison/pen/vYpPGwG" target="_blank" rel="noopener"&gt;sample in CodePen&lt;/A&gt; showing how it can be done. Basically, you don't have to do anything special when you create the second &lt;FONT face="andale mono,times"&gt;DrawAction&lt;/FONT&gt;; it never needs to know that you already had some vertices when you began. What's different is that, when you create/update the graphic that represents the user's drawing, you create the geometry using your initial vertices plus (concatenated with) the vertices from the &lt;FONT face="andale mono,times"&gt;DrawAction&lt;/FONT&gt; event.&lt;/P&gt;&lt;P&gt;The CodePen sample is a modified version of the &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/draw-line/" target="_self"&gt;Draw polyline sample&lt;/A&gt; that you mentioned. I modified it to demonstrate how, given four existing vertices, a &lt;FONT face="andale mono,times"&gt;PolylineDrawAction&lt;/FONT&gt; can be used to "continue drawing" that polyline — i.e. to draw a polyline with the first four vertices already defined. I also stripped out all code from the original sample related to checking for self-intersection. I've explained more in comments in the code, but I've also left most of the comments from the original. You can distinguish mine because they start with &lt;FONT face="andale mono,times"&gt;// TM:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Let me know if this approach works for you, and/or if you need any clarification of the sample.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 00:58:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pause-or-resume-draw-or-drawaction-or-add-vertices/m-p/1166481#M77077</guid>
      <dc:creator>TristanMorrison</dc:creator>
      <dc:date>2022-04-21T00:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Pause or Resume Draw or DrawAction, or Add Vertices to Draw or DrawAction Programmatically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pause-or-resume-draw-or-drawaction-or-add-vertices/m-p/1166491#M77079</link>
      <description>&lt;P&gt;Thank you, Tristan. That is a good approach that gets me 90% of the way there. The only thing left to do is figure out how to let the user double-click the last point immediately after resuming. If the user single-clicks at least one point and then double-clicks a point, it's fine. But if the user double-clicks without single-clicking any points, a vertex is added but the drawing continues. If you have any ideas for solving that, let me know. Thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 01:37:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pause-or-resume-draw-or-drawaction-or-add-vertices/m-p/1166491#M77079</guid>
      <dc:creator>GaryLSheppardJr</dc:creator>
      <dc:date>2022-04-21T01:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Pause or Resume Draw or DrawAction, or Add Vertices to Draw or DrawAction Programmatically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pause-or-resume-draw-or-drawaction-or-add-vertices/m-p/1167153#M77113</link>
      <description>&lt;P&gt;I have a fix for that double-click behavior&amp;nbsp;&lt;EM&gt;for polylines&lt;/EM&gt;. Once I get it working for polygons too, I'll share what I did. Thanks again for the head start!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 18:51:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pause-or-resume-draw-or-drawaction-or-add-vertices/m-p/1167153#M77113</guid>
      <dc:creator>GaryLSheppardJr</dc:creator>
      <dc:date>2022-04-22T18:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Pause or Resume Draw or DrawAction, or Add Vertices to Draw or DrawAction Programmatically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pause-or-resume-draw-or-drawaction-or-add-vertices/m-p/1377226#M83520</link>
      <description>&lt;P&gt;Gary, I came across this post as I am having the same issue when resuming a polyline drawing. I know some time has passed, but I am very curious how you were able to solve the double-click problem. Do you still have a copy of your code you can share? Thanks in advance!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 19:31:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/pause-or-resume-draw-or-drawaction-or-add-vertices/m-p/1377226#M83520</guid>
      <dc:creator>AngelaSuffia</dc:creator>
      <dc:date>2024-02-01T19:31:00Z</dc:date>
    </item>
  </channel>
</rss>

