<?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 AddVertex issue in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/addvertex-issue/m-p/368390#M4358</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We would like to add a vertex to the editor from code behind.&amp;nbsp; We would like the first point to be fixed and the user select the second point.&amp;nbsp; We are unable to get the AddVertex command to execute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Task t = this.Editor.RequestShapeAsync(Esri.ArcGISRuntime.Controls.DrawShape.Polygon);&lt;/P&gt;&lt;P&gt;this.Editor.AddVertex.Execute(new MapPoint(0, 0));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We receive an ArgumentException was unhandled by user code, "Cannot execute command."&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Nov 2014 19:17:49 GMT</pubDate>
    <dc:creator>KeithMacIntyre</dc:creator>
    <dc:date>2014-11-18T19:17:49Z</dc:date>
    <item>
      <title>AddVertex issue</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/addvertex-issue/m-p/368390#M4358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We would like to add a vertex to the editor from code behind.&amp;nbsp; We would like the first point to be fixed and the user select the second point.&amp;nbsp; We are unable to get the AddVertex command to execute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Task t = this.Editor.RequestShapeAsync(Esri.ArcGISRuntime.Controls.DrawShape.Polygon);&lt;/P&gt;&lt;P&gt;this.Editor.AddVertex.Execute(new MapPoint(0, 0));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We receive an ArgumentException was unhandled by user code, "Cannot execute command."&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2014 19:17:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/addvertex-issue/m-p/368390#M4358</guid>
      <dc:creator>KeithMacIntyre</dc:creator>
      <dc:date>2014-11-18T19:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: AddVertex issue</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/addvertex-issue/m-p/368391#M4359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem here seems to be that the vertex is added too quickly - before the Editor has a chance to initialize its drawing resources.&amp;nbsp; In this case, the MapView.Editor.AddVertex.CanExecute method would return false.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to wait for the Editor to catch up like this instead:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #303030;"&gt;// Start the Editor polygon drawing process&lt;/SPAN&gt;
&lt;SPAN style="color: #303030;"&gt;var tcs = new TaskCompletionSource&amp;lt;bool&amp;gt;();&lt;/SPAN&gt;
&lt;SPAN style="color: #303030;"&gt;EventHandler handler = (s, a) =&amp;gt; { tcs.SetResult(true); };&lt;/SPAN&gt;
&lt;SPAN style="color: #303030;"&gt;MyMapView.Editor.AddVertex.CanExecuteChanged += handler;&lt;/SPAN&gt;
&lt;SPAN style="color: #303030;"&gt;var drawTask = MyMapView.Editor.RequestShapeAsync(DrawShape.Polygon);&lt;/SPAN&gt;
&lt;SPAN style="color: #303030;"&gt;await tcs.Task;&lt;/SPAN&gt;
&lt;SPAN style="color: #303030;"&gt;MyMapView.Editor.AddVertex.CanExecuteChanged -= handler;&lt;/SPAN&gt;

&lt;SPAN style="color: #303030;"&gt;// After Editor initialization, add a fixed initial point&lt;/SPAN&gt;
&lt;SPAN style="color: #303030;"&gt;MyMapView.Editor.AddVertex.Execute(MyMapView.Extent.GetCenter());&lt;/SPAN&gt;

&lt;SPAN style="color: #303030;"&gt;// Now get the rest of the points from the user&lt;/SPAN&gt;
&lt;SPAN style="color: #303030;"&gt;var poly = await drawTask as Polygon;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030;"&gt;This should allow you to set a fixed starting point for the polygon and let the user fill in the rest.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030;"&gt;-Greg&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:05:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/addvertex-issue/m-p/368391#M4359</guid>
      <dc:creator>GregDeStigter</dc:creator>
      <dc:date>2021-12-11T17:05:09Z</dc:date>
    </item>
  </channel>
</rss>

