<?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: How to clone a graphic to a new Graphics layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-clone-a-graphic-to-a-new-graphics-layer/m-p/552764#M51555</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That works perfectly... Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Apr 2016 14:51:55 GMT</pubDate>
    <dc:creator>YogiPatel</dc:creator>
    <dc:date>2016-04-21T14:51:55Z</dc:date>
    <item>
      <title>How to clone a graphic to a new Graphics layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-clone-a-graphic-to-a-new-graphics-layer/m-p/552761#M51552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I'm a bit new to Javascript and the JSAPI, and am running into an issue. &lt;/P&gt;&lt;P&gt;I have an app with two maps. In the app, the user populates the first map by submitting a findTask. The results (points) are added to a Graphics layer. The user then is able to click on points they want to select for further analysis, and those points are copied to the second map. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem I'm having is when I copy the graphics to a new Graphics layer for the second map, they disappear from the first map. I'm seeing in Flex that there is a "graphic.Geometry.Clone()" function that allows one to clone points. Is there an equivalent in JSAPI? Or is there any other way I can copy (not cut) points from one map to the other?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;array.map(firstLayer.graphics, function (graphic) {
&amp;nbsp; if (graphic.attributes["selected"] == true) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; secondLayer.add(graphic);
&amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.setSymbol(Selected_Marker);
&amp;nbsp; }
});&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:53:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-clone-a-graphic-to-a-new-graphics-layer/m-p/552761#M51552</guid>
      <dc:creator>YogiPatel</dc:creator>
      <dc:date>2021-12-11T23:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to clone a graphic to a new Graphics layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-clone-a-graphic-to-a-new-graphics-layer/m-p/552762#M51553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could simplly create a new graphic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var newGraphic = new Graphic(oldGraphic.toJson());&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2016 14:43:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-clone-a-graphic-to-a-new-graphics-layer/m-p/552762#M51553</guid>
      <dc:creator>thejuskambi</dc:creator>
      <dc:date>2016-04-21T14:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to clone a graphic to a new Graphics layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-clone-a-graphic-to-a-new-graphics-layer/m-p/552763#M51554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should be able to accomplish this by &lt;A href="https://developers.arcgis.com/javascript/jsapi/graphic-amd.html#tojson" rel="nofollow noopener noreferrer" target="_blank"&gt;getting the JSON&lt;/A&gt; object from the Graphic and then creating a new Graphic &lt;A href="https://developers.arcgis.com/javascript/jsapi/graphic-amd.html#graphic2" rel="nofollow noopener noreferrer" target="_blank"&gt;using the JSON object&lt;/A&gt;. It would look something like this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;require(["esri/graphic"], function(Graphic) {

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; … you code here …

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphicJSON = originalGraphic.toJson()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphicCopy = new Graphic(graphicJSON)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; … you code here …

});&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There may be a more elegant way to this, but this approach is the first one that comes to my mind.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:53:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-clone-a-graphic-to-a-new-graphics-layer/m-p/552763#M51554</guid>
      <dc:creator>DavidBlanchard</dc:creator>
      <dc:date>2021-12-11T23:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to clone a graphic to a new Graphics layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-clone-a-graphic-to-a-new-graphics-layer/m-p/552764#M51555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That works perfectly... Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2016 14:51:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-clone-a-graphic-to-a-new-graphics-layer/m-p/552764#M51555</guid>
      <dc:creator>YogiPatel</dc:creator>
      <dc:date>2016-04-21T14:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to clone a graphic to a new Graphics layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-clone-a-graphic-to-a-new-graphics-layer/m-p/1116143#M75261</link>
      <description>&lt;P&gt;Nifty little trick! Very useful.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Nov 2021 22:34:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-clone-a-graphic-to-a-new-graphics-layer/m-p/1116143#M75261</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2021-11-11T22:34:30Z</dc:date>
    </item>
  </channel>
</rss>

