<?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: 'Access of possibly undefined property' error when casting map.layer as FeatureLa in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/access-of-possibly-undefined-property-error-when/m-p/1911#M31</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; On Number 2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; You can use a QueryTask on a Map Service Layer that is not added to the map. The results of the query can be graphics that can be added to the map to fulfill your desire to have the features highlighted.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Apr 2011 17:22:22 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2011-04-14T17:22:22Z</dc:date>
    <item>
      <title>'Access of possibly undefined property' error when casting map.layer as FeatureLayer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/access-of-possibly-undefined-property-error-when/m-p/1909#M29</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A couple of questions, one specific and one more general.&amp;nbsp; Specific first:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- I'm attempting to modify the selectedFeatures of one of my map FeatureLayers. I set up my query and then have the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
var fLayer:FeatureLayer;
for each (var lyr:Layer in map.layers)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((lyr is FeatureLayer) &amp;amp;&amp;amp; (lyr.url == queryUrl)) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fLayer = FeatureLayer(lyr);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}

var selectionMethod:String = FeatureLayer.SELECTION_NEW;
fLayer.selectFeatures(facsQuery, selectionMethod, new AsyncResponder(onSelectResult, onSelectFault, fLayer));
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm hoping this will highlight the selected features in a map layer that already exists, rather than create a 'new FeatureLayer()', which adds another (unwanted) layer to my map (and layer picker -- I'm using the v2.2 Flex Viewer).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At compile time, I'm getting the error '1119:&amp;nbsp; Access of possibly undefined property url through a reference with static type com.esri.ags.layers.Layer'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a better way to do what I'm trying to do?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now the more general question:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Ultimately I want to highlight multiple features in multiple layers.&amp;nbsp; I have to use a query since my where clause is 'ID in (123,456,789)'.&amp;nbsp; While a Find task will query multiple fields in multiple layers, it only allows a simple search string, i.e. I can't define a query w/ a where clause, etc.&amp;nbsp; So I have to use a query.&amp;nbsp; Also, if I want to take advantage of the selectedFeatures highlighting, then I have to define a query and run FeatureLayer.selectFeatures() as in my code above.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I could do something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- loop through each layer to be searched and increment a counter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- decrement the counter each time I get a result&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- zoom to my features when counter = 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Should I do something else instead like use a hidden layer that has all features of my multiple layers, query that one layer, and hide it from the layer selector (if possible)?&amp;nbsp; The multiple layers that I'm searching are views of a single feature class, so this may be the way to go if there's a way to query that layer and render the features on the map even though I don't want the layer itself on the map or in the layer picker.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 07:00:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/access-of-possibly-undefined-property-error-when/m-p/1909#M29</guid>
      <dc:creator>ChrisBeaudette</dc:creator>
      <dc:date>2011-04-14T07:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: 'Access of possibly undefined property' error when casting map.layer as FeatureLa</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/access-of-possibly-undefined-property-error-when/m-p/1910#M30</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My bad on #1:&amp;nbsp; a 'Layer' object doesn't have 'url' property -- only the subclassed 'FeatureLayer' does.&amp;nbsp; Fixed this by doing the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var fLayer:FeatureLayer;
for each (var lyr:Layer in map.layers)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (lyr is FeatureLayer) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fLayer = FeatureLayer(lyr);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((fLayer != null) &amp;amp;&amp;amp; (fLayer.url == queryUrl))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}

var selectionMethod:String = FeatureLayer.SELECTION_NEW;
fLayer.selectFeatures(facsQuery, selectionMethod, new AsyncResponder(onSelectResult, onSelectFault, fLayer));&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would still be interested to know thoughts on #2 though.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:05:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/access-of-possibly-undefined-property-error-when/m-p/1910#M30</guid>
      <dc:creator>ChrisBeaudette</dc:creator>
      <dc:date>2021-12-10T20:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: 'Access of possibly undefined property' error when casting map.layer as FeatureLa</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/access-of-possibly-undefined-property-error-when/m-p/1911#M31</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; On Number 2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; You can use a QueryTask on a Map Service Layer that is not added to the map. The results of the query can be graphics that can be added to the map to fulfill your desire to have the features highlighted.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2011 17:22:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/access-of-possibly-undefined-property-error-when/m-p/1911#M31</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2011-04-14T17:22:22Z</dc:date>
    </item>
  </channel>
</rss>

