<?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 Cant move graphic in graphicslayer programatically in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cant-move-graphic-in-graphicslayer-programatically/m-p/1167624#M77125</link>
    <description>&lt;P&gt;I want to move the points of a graphic created with the Sketch Widget programatically. Unfortunately I am seeing that when I change the geometry of a graphic via code, the graphic is not visible. I am wondering if there is a general approach toward manually editing locations of vertices in a graphics layer or if moving it via the map is the only way.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a snippet of code showing my approach. Here is a Codepen for reproducing the problem:&amp;nbsp;&lt;A href="https://codepen.io/coxfsi/pen/mdpZbrG" target="_blank" rel="noopener"&gt;https://codepen.io/coxfsi/pen/mdpZbrG&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;        if (graphicsLayer.graphics.length &amp;gt; 0){
          let lineGraphic= graphicsLayer.graphics.getItemAt(0);
          
          // Can't edit the geometry directly due to iterable error
          // lineGraphic.geometry.paths[0][0] = 1000000; 
          
          // editing a point belonging to a clone does not throw error, but the line is invisible
          let copyGraphic = lineGraphic.clone();
          viewModel.layer.removeAll();
           copyGraphic.geometry.paths[0][0] = 11311599;
           viewModel.layer.add(copyGraphic);
           viewModel.update(copyGraphic);
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Apr 2022 18:00:14 GMT</pubDate>
    <dc:creator>ironmaskito</dc:creator>
    <dc:date>2022-04-25T18:00:14Z</dc:date>
    <item>
      <title>Cant move graphic in graphicslayer programatically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cant-move-graphic-in-graphicslayer-programatically/m-p/1167624#M77125</link>
      <description>&lt;P&gt;I want to move the points of a graphic created with the Sketch Widget programatically. Unfortunately I am seeing that when I change the geometry of a graphic via code, the graphic is not visible. I am wondering if there is a general approach toward manually editing locations of vertices in a graphics layer or if moving it via the map is the only way.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a snippet of code showing my approach. Here is a Codepen for reproducing the problem:&amp;nbsp;&lt;A href="https://codepen.io/coxfsi/pen/mdpZbrG" target="_blank" rel="noopener"&gt;https://codepen.io/coxfsi/pen/mdpZbrG&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;        if (graphicsLayer.graphics.length &amp;gt; 0){
          let lineGraphic= graphicsLayer.graphics.getItemAt(0);
          
          // Can't edit the geometry directly due to iterable error
          // lineGraphic.geometry.paths[0][0] = 1000000; 
          
          // editing a point belonging to a clone does not throw error, but the line is invisible
          let copyGraphic = lineGraphic.clone();
          viewModel.layer.removeAll();
           copyGraphic.geometry.paths[0][0] = 11311599;
           viewModel.layer.add(copyGraphic);
           viewModel.update(copyGraphic);
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 18:00:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cant-move-graphic-in-graphicslayer-programatically/m-p/1167624#M77125</guid>
      <dc:creator>ironmaskito</dc:creator>
      <dc:date>2022-04-25T18:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Cant move graphic in graphicslayer programatically</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cant-move-graphic-in-graphicslayer-programatically/m-p/1167759#M77127</link>
      <description>&lt;P&gt;You are getting this error because you are corrupting your polyline geometry. For example, the polyline is going from:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[9316221.444425754, 5694060.22603468]
[10270155.5574245, 6091609.210145776]

To 
11311599
[10270155.5574245, 6091609.210145776]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-04-25 at 3.49.46 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/39824i3F4CDAFEB43EDE00/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2022-04-25 at 3.49.46 PM.png" alt="Screen Shot 2022-04-25 at 3.49.46 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You should use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#methods-summary" target="_self"&gt;Polyline.setPoint&lt;/A&gt; method to update the vertices or the other methods to change the polyline geometry. Or you have to make sure that you are changing the right values in the array without corrupting the array of vertices. The following for example works in your app:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;copyGraphic.geometry.paths[0][0][0] = firstGraphic.geometry.paths[0][0][0] + 300000; 
copyGraphic.geometry.paths[0][0][1] = firstGraphic.geometry.paths[0][0][1] + 300000; &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 22:53:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cant-move-graphic-in-graphicslayer-programatically/m-p/1167759#M77127</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2022-04-25T22:53:58Z</dc:date>
    </item>
  </channel>
</rss>

