<?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: Lang.Hitch selectFeatures in featureCollection in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463369#M42806</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I declared a global variable at the beginning of the app&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var FLayer;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and inside ShowSelectedFeatures() I used your suggestion. Still same error.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;"&gt;// Create a new feature layer&lt;/SPAN&gt;
FLayer &lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;"&gt;=&lt;/SPAN&gt; &lt;SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;"&gt;new&lt;/SPAN&gt; &lt;SPAN class="" style="border: 0px; font-weight: inherit;"&gt;FeatureLayer&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;(&lt;/SPAN&gt;featureCollection&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;,&lt;/SPAN&gt; &lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;{&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 20:34:49 GMT</pubDate>
    <dc:creator>ThaoLe1</dc:creator>
    <dc:date>2021-12-11T20:34:49Z</dc:date>
    <item>
      <title>Lang.Hitch selectFeatures in featureCollection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463367#M42804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have these codes.&amp;nbsp; I'm wondering how do I use Lang.Hitch for this because of this error &lt;STRONG&gt;TypeError:&amp;nbsp;Cannot read property 'selectFeatures' of undefined.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;function CreateGraphics (evt) {&lt;/P&gt;&lt;P&gt;CODES HERE.......................&lt;BR /&gt; &lt;BR /&gt; var graphics5= new Graphic(geoBuffer, symbolBuffer, attr5, infoTemplate5); &lt;BR /&gt; //map.graphics.add(graphics5);&lt;BR /&gt; ShowSelectedFeatures (graphics5); &lt;BR /&gt;} &lt;BR /&gt; &lt;BR /&gt;/////////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt; &lt;BR /&gt;function ShowSelectedFeatures(graphicsLine) {&lt;/P&gt;&lt;P&gt;var featureCollection = {&lt;BR /&gt; "layerDefinition": null,&lt;BR /&gt; "featureSet": {&lt;BR /&gt; "features":graphicsLine,&lt;BR /&gt; "geometryType": "esriGeometryLine"&lt;BR /&gt; }&lt;BR /&gt; };&lt;BR /&gt; &lt;BR /&gt; featureCollection.layerDefinition = {&lt;BR /&gt; "geometryType": "esriGeometryLine",&lt;BR /&gt; "objectIdField": "ObjectID",&lt;BR /&gt; &lt;BR /&gt; "fields": [{&lt;BR /&gt; "name": "ObjectID",&lt;BR /&gt; "alias": "ObjectID",&lt;BR /&gt; "type": "esriFieldTypeOID"&lt;BR /&gt; }]&lt;BR /&gt; };&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; // Create a new feature layer&lt;BR /&gt; var FLayer = new FeatureLayer(featureCollection, {&lt;BR /&gt; mode: FeatureLayer.MODE_SELECTION,&lt;BR /&gt; outFields: ["*"],&lt;BR /&gt; infoTemplate: infoTemp&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;FLayer.setSelectionSymbol(lineSymb); &lt;BR /&gt; map.addLayer(FLayer);&lt;BR /&gt; &lt;BR /&gt;} &lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////////// &lt;BR /&gt; &lt;BR /&gt;FLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (evt) { &lt;BR /&gt; &lt;BR /&gt;CODES HERE .................................&lt;BR /&gt; &lt;BR /&gt;});&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Oct 2017 19:30:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463367#M42804</guid>
      <dc:creator>ThaoLe1</dc:creator>
      <dc:date>2017-10-24T19:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Lang.Hitch selectFeatures in featureCollection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463368#M42805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thao,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;It looks like your FLayer is a local var inside of the&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;ShowSelectedFeatures function and that your call to&amp;nbsp;&lt;SPAN&gt;FLayer.selectFeatures is outside of that functions scope. So in that case the FLayer is always going to be null unless you declare the&amp;nbsp;FLayer var higher in your apps scope. So you need to declare the&amp;nbsp;FLayer var at the begining of your app and then inside the&amp;nbsp;ShowSelectedFeatures&amp;nbsp;you would just use&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;// Create a new feature layer&lt;/SPAN&gt;
FLayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;FeatureLayer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;featureCollection&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:34:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463368#M42805</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-11T20:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Lang.Hitch selectFeatures in featureCollection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463369#M42806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I declared a global variable at the beginning of the app&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var FLayer;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and inside ShowSelectedFeatures() I used your suggestion. Still same error.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;"&gt;// Create a new feature layer&lt;/SPAN&gt;
FLayer &lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;"&gt;=&lt;/SPAN&gt; &lt;SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;"&gt;new&lt;/SPAN&gt; &lt;SPAN class="" style="border: 0px; font-weight: inherit;"&gt;FeatureLayer&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;(&lt;/SPAN&gt;featureCollection&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;,&lt;/SPAN&gt; &lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;{&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:34:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463369#M42806</guid>
      <dc:creator>ThaoLe1</dc:creator>
      <dc:date>2021-12-11T20:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Lang.Hitch selectFeatures in featureCollection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463370#M42807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thao,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I would have to see more of your code then.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Oct 2017 20:28:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463370#M42807</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-10-24T20:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Lang.Hitch selectFeatures in featureCollection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463371#M42808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The error message is indicating that the Flayer variable is not initialized at the time the selectFeatures is called. You need ensure that the Flayer is initialized and or loaded on the the map before selecting features from it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest to move the selectFeatures code in ShowSelectedFeatures method and also call it after the layer is loaded/added to map event.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Oct 2017 20:39:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463371#M42808</guid>
      <dc:creator>thejuskambi</dc:creator>
      <dc:date>2017-10-24T20:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Lang.Hitch selectFeatures in featureCollection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463372#M42809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert, could you verify the&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;ShowSelectedFeatures() function for featureCollection and its syntax is reasonably correct?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Oct 2017 20:54:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463372#M42809</guid>
      <dc:creator>ThaoLe1</dc:creator>
      <dc:date>2017-10-24T20:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Lang.Hitch selectFeatures in featureCollection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463373#M42810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thao,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I am not sure a FeatureLayer created from a FeatureCollection supports the selectFeature method. I will test some and get back with you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 00:02:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463373#M42810</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-10-25T00:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Lang.Hitch selectFeatures in featureCollection</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463374#M42811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thao,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;So geometry based queries work fine but a query that uses a where clause is not supported.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 00:06:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/lang-hitch-selectfeatures-in-featurecollection/m-p/463374#M42811</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-10-25T00:06:45Z</dc:date>
    </item>
  </channel>
</rss>

