<?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: converting selected map service layer as graphics using esri js api in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/converting-selected-map-service-layer-as-graphics/m-p/1165506#M77041</link>
    <description>&lt;P&gt;I understood, graphic is a high level geometry and I am passing low level geometry to it(i.e., paths).&lt;/P&gt;&lt;P&gt;Even I tried with&amp;nbsp;&lt;/P&gt;&lt;P&gt;new Graphic(evt.graphic.toJson())&lt;/P&gt;&lt;P&gt;new Polyline( evt.graphic.geometry.toJson())&lt;/P&gt;&lt;P&gt;breakpoint shows the proper json construction, but Graphic and Polyline not able to understand this high level geometry.&amp;nbsp; Can any body help.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Apr 2022 00:03:03 GMT</pubDate>
    <dc:creator>JayakumarPD</dc:creator>
    <dc:date>2022-04-19T00:03:03Z</dc:date>
    <item>
      <title>converting selected map service layer as graphics using esri js api</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/converting-selected-map-service-layer-as-graphics/m-p/1165085#M77034</link>
      <description>&lt;P&gt;Hi, am I thinking in a right way, kindly guide.&lt;/P&gt;&lt;P&gt;Challenge: selecting a map service(polyline) by using click event and adding that selected map service(polyline) as graphics.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// defined a map 
map = new Map("map", {
      basemap: "topo-vector",
      center: [-146.87045, 63.227787],
      zoom: 7,
      logo: false,
    });
// added the layer
  var featureLayerSample = new FeatureLayer(
"https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/0",
      {
        mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
        outFields: ["*"],
      }
    );
   map.addLayer(featureLayerSample);
// on click function
map.on("click", showRoadName);
// function definition
function showRoadName(evt) {
      console.log(evt);
// here i am getting the information about the map service
      document.getElementById("distName").innerHTML = evt.graphic.attributes.ROUTE;
     // here i am getting the path array
      var mypaths = evt.graphic.geometry.paths[0];
      var mypathsLenth = evt.graphic.geometry.paths[0].length;
// simple custom symbology
var symbol = new SimpleLineSymbol({color:[100, 200, 0], width:4});
// I passed the, array stright to new graphic. Thinking that, it will understand and add it as graphic, but failed
map.graphics.add(new Graphic(mypaths, symbol));
}
// second method, i created an object
     var myObject ={
        paths:[],
         spatialReference:{"wkid": 102100}
       }
// for the path pushed the array
 for(var i=0; i &amp;lt; mypathsLenth; i++){
         console.log(mypaths[i]);
         myObject.paths.push("["+mypaths[i]+"]");
      }
// defined the polyline
 var singlePathPolyline = new Polyline(myObject);
//trying to add, but still not able to add
 map.graphics.add(new Graphic(singlePathPolyline, symbol));&lt;/LI-CODE&gt;&lt;P&gt;I am confused, do I am thinking properly to add. Or my way is wrong.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or is there any simple way, where I can convert the selected map service as graphics.&amp;nbsp; Pls help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;for first method, not giving any error, but for second --&amp;gt; polyline is not a constructor.&amp;nbsp; error is coming.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 04:37:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/converting-selected-map-service-layer-as-graphics/m-p/1165085#M77034</guid>
      <dc:creator>JayakumarPD</dc:creator>
      <dc:date>2022-04-18T04:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: converting selected map service layer as graphics using esri js api</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/converting-selected-map-service-layer-as-graphics/m-p/1165506#M77041</link>
      <description>&lt;P&gt;I understood, graphic is a high level geometry and I am passing low level geometry to it(i.e., paths).&lt;/P&gt;&lt;P&gt;Even I tried with&amp;nbsp;&lt;/P&gt;&lt;P&gt;new Graphic(evt.graphic.toJson())&lt;/P&gt;&lt;P&gt;new Polyline( evt.graphic.geometry.toJson())&lt;/P&gt;&lt;P&gt;breakpoint shows the proper json construction, but Graphic and Polyline not able to understand this high level geometry.&amp;nbsp; Can any body help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 00:03:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/converting-selected-map-service-layer-as-graphics/m-p/1165506#M77041</guid>
      <dc:creator>JayakumarPD</dc:creator>
      <dc:date>2022-04-19T00:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: converting selected map service layer as graphics using esri js api</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/converting-selected-map-service-layer-as-graphics/m-p/1165560#M77044</link>
      <description>&lt;P&gt;I realised, I was on a wrong way.&amp;nbsp; This worked for me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let graphicJson = evt.graphic.geometry.toJson();
let highLevelGeometry = esri.geometry.fromJson(graphicJson);
var symbol = new SimpleLineSymbol(
          SimpleLineSymbol.STYLE_DASH,
          new Color([0,0,250]),
          3
        );
map.graphics.add(new Graphic(highLevelGeometry, symbol));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 09:51:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/converting-selected-map-service-layer-as-graphics/m-p/1165560#M77044</guid>
      <dc:creator>JayakumarPD</dc:creator>
      <dc:date>2022-04-19T09:51:12Z</dc:date>
    </item>
  </channel>
</rss>

