<?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: Getting Layer name from Graphic object in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697789#M15586</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great idea but now I see that graphicsLayer is null for all Graphic objects, I have to check why is that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, the problem is solved for now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Jul 2013 06:14:29 GMT</pubDate>
    <dc:creator>bojko108</dc:creator>
    <dc:date>2013-07-18T06:14:29Z</dc:date>
    <item>
      <title>Getting Layer name from Graphic object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697784#M15581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm making a widget that asks user to make a selection and then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fills an information about selected objects in a Tree Control.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It searches all the operational layers loaded on the map and executes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;spatial query to get FeatureSet for every layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using this function to get result from the query and to put the selected &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;objects in ArrayCollection, later used as dataprovider for Tree Control:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;private function onResult(featureSet:FeatureSet, token:Object = null):void {&amp;nbsp;&amp;nbsp; var queryLayer:FeatureLayer = null;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(token != null &amp;amp;&amp;amp; token.hasOwnProperty("layer")){ &amp;nbsp; queryLayer = token["layer"];&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; if(featureSet.features.length &amp;gt; 0){ &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // ArrayCollection holding selected objects by layers &amp;nbsp;&amp;nbsp; this.SelectedObjectsMap.addItem({label: queryLayer.name, children: new ArrayCollection(featureSet.features)}); &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // tree control &amp;nbsp;&amp;nbsp; this.treeSelection.dataProvider = this.SelectedObjectsMap; &amp;nbsp; }&amp;nbsp; } }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This function I'm using to label all the items in Tree Contrrol:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;private function treeLabeling(item:Object):String{&amp;nbsp;&amp;nbsp; // here I need information about Layer name&amp;nbsp; if(item is Graphic){ &amp;nbsp; return (item as Graphic).attributes["STATE_NAME"].toString();&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; return item.label; }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that here I need to know from which Layer is this object. Is it possible to get this information from Graphic object, or FeatureSet collection?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;---&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bogdan Hristozov&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Pontech Bulgaria&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Jul 2013 10:29:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697784#M15581</guid>
      <dc:creator>bojko108</dc:creator>
      <dc:date>2013-07-14T10:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Layer name from Graphic object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697785#M15582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bogdan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; you already know have the layer object when you add it to your SelectedObjectsMap. So why not just add the layer as a property of the SelectedObjectsMap object that you add? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You also add the layers name to the SelectedObjectsMap so you could just take that label and loop the map layer searching for the layer with that name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Probably the best solution would be to grab the layerId of the layer in the map when you add it to the SelectedObjectsMap and add that as a property of the object you add that way the object is very light weight and you can just use a line like this to get the layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;var lyr:Layer = map.getLayer("yourLayerId");&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Jul 2013 18:54:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697785#M15582</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2013-07-14T18:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Layer name from Graphic object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697786#M15583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for replay Robert,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm new in Flex programming and the problem is that I can't set custom dataprovider for Tree Control. First I made a class holding information about feature layer and selected objects, but when adding this class as dataprovider for Tree Control nothing was working. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As you can see I'm adding &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;featureSet.features&lt;/SPAN&gt;&lt;SPAN&gt; in Tree Control, which is Array of Graphic objects and when I am in &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;treeLabeling(item:Object):String function&lt;/SPAN&gt;&lt;SPAN&gt;, type of item is Graphic and I don't have information about feature layer. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I solve the problem by getting parent node for selected item. For each child item in Tree Control I have parent item which has information about feature layer. The question is more general. Can I get feature layer from Graphic object.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jul 2013 07:33:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697786#M15583</guid>
      <dc:creator>bojko108</dc:creator>
      <dc:date>2013-07-17T07:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Layer name from Graphic object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697787#M15584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bogdan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; No there is not that I am aware of.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jul 2013 11:53:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697787#M15584</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2013-07-17T11:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Layer name from Graphic object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697788#M15585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Can I get feature layer from Graphic object.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can use the "graphicsLayer" property on Graphic. FeatureLayer extends GraphicsLayer so you can cast to FeatureLayer if you need to.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/Graphic.html#graphicsLayer" rel="nofollow" target="_blank"&gt;https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/Graphic.html#graphicsLayer&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jul 2013 15:20:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697788#M15585</guid>
      <dc:creator>DasaPaddock</dc:creator>
      <dc:date>2013-07-17T15:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Layer name from Graphic object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697789#M15586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great idea but now I see that graphicsLayer is null for all Graphic objects, I have to check why is that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, the problem is solved for now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2013 06:14:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/getting-layer-name-from-graphic-object/m-p/697789#M15586</guid>
      <dc:creator>bojko108</dc:creator>
      <dc:date>2013-07-18T06:14:29Z</dc:date>
    </item>
  </channel>
</rss>

