<?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 FeatureLayer selectFeatures only displays one feature in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-selectfeatures-only-displays-one/m-p/731676#M67803</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am creating a select features tool.&amp;nbsp; It will work as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The user draws a polygon&lt;/LI&gt;&lt;LI&gt;The draw-end event fires a function that runs an identifyTask to query the visible layers (NB. the identifyTask does NOT return the geometry).&lt;/LI&gt;&lt;LI&gt;The callback function from the identifyTask loops through the results set and creates four arrays - a list of the layers, a list of the ids, a list of the geometry types and a corresponding set of HTML tables detailing the feature attributes for that layer&lt;/LI&gt;&lt;LI&gt;The first array is used to create a drop-down list of layers, and when the selection changes, the display changes to display the relevant table.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far so straightforward.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also want the selected features to be highlighted when the layer selection is changed.&amp;nbsp; To achieve this I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Created a featureLayer (using the id from the array) with the mode set as MODE_SELECTION&lt;/LI&gt;&lt;LI&gt;Set the selection symbol (uses the geometry type array to determine what type of symbol this should be)&lt;/LI&gt;&lt;LI&gt;Created a queryTask using the geometry of the polygon created in the first step&lt;/LI&gt;&lt;LI&gt;Run the selectFeatures method on the featureLayer using the queryTask&lt;/LI&gt;&lt;LI&gt;Added the featureLayer to the map.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, only the first feature in each layer is highlighted.&amp;nbsp; Yet if I look at the query results in the browser console I can see multiple results are returned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I missing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sarah Noakes&lt;/P&gt;&lt;P&gt;Cornwall Council&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 May 2015 13:56:31 GMT</pubDate>
    <dc:creator>SarahNoakes1</dc:creator>
    <dc:date>2015-05-22T13:56:31Z</dc:date>
    <item>
      <title>FeatureLayer selectFeatures only displays one feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-selectfeatures-only-displays-one/m-p/731676#M67803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am creating a select features tool.&amp;nbsp; It will work as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The user draws a polygon&lt;/LI&gt;&lt;LI&gt;The draw-end event fires a function that runs an identifyTask to query the visible layers (NB. the identifyTask does NOT return the geometry).&lt;/LI&gt;&lt;LI&gt;The callback function from the identifyTask loops through the results set and creates four arrays - a list of the layers, a list of the ids, a list of the geometry types and a corresponding set of HTML tables detailing the feature attributes for that layer&lt;/LI&gt;&lt;LI&gt;The first array is used to create a drop-down list of layers, and when the selection changes, the display changes to display the relevant table.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far so straightforward.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also want the selected features to be highlighted when the layer selection is changed.&amp;nbsp; To achieve this I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Created a featureLayer (using the id from the array) with the mode set as MODE_SELECTION&lt;/LI&gt;&lt;LI&gt;Set the selection symbol (uses the geometry type array to determine what type of symbol this should be)&lt;/LI&gt;&lt;LI&gt;Created a queryTask using the geometry of the polygon created in the first step&lt;/LI&gt;&lt;LI&gt;Run the selectFeatures method on the featureLayer using the queryTask&lt;/LI&gt;&lt;LI&gt;Added the featureLayer to the map.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, only the first feature in each layer is highlighted.&amp;nbsp; Yet if I look at the query results in the browser console I can see multiple results are returned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I missing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sarah Noakes&lt;/P&gt;&lt;P&gt;Cornwall Council&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 13:56:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-selectfeatures-only-displays-one/m-p/731676#M67803</guid>
      <dc:creator>SarahNoakes1</dc:creator>
      <dc:date>2015-05-22T13:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer selectFeatures only displays one feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-selectfeatures-only-displays-one/m-p/731677#M67804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have any code you could share?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did notice on the&lt;A href="https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html#selectfeatures"&gt; API page&lt;/A&gt; that for 'MODE_SELECTION' there are specific instructions about adding features:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL style="margin: 0.5em 0 0; list-style-position: inside; padding-left: 1.6em; color: #595959; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif;"&gt;&lt;LI&gt;Call the selectFeatures method.&lt;/LI&gt;&lt;LI&gt;Listen for the onSelectionComplete event.&lt;/LI&gt;&lt;LI&gt;Once onSelectionComplete fires, retrieve the selected features using the getSelectedFeatures method.&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 18:45:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-selectfeatures-only-displays-one/m-p/731677#M67804</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2015-05-22T18:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer selectFeatures only displays one feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-selectfeatures-only-displays-one/m-p/731678#M67805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sarah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for getting back to me.&amp;nbsp; I've figured it out now - It was to do with how I was creating the FeatureLayer.&amp;nbsp; I had:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;featureLayerSelectManyURL = intranetMapServiceURL + "/" + arrTableIds[0];&lt;/P&gt;&lt;P&gt;featureLayerSelectMany = new FeatureLayer(featureLayerSelectManyURL, {mode: FeatureLayer.MODE_SELECTION});&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;whereas what I needed was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;featureLayerSelectManyURL = intranetMapServiceURL + "/" + arrTableIds[0];&lt;/P&gt;&lt;P&gt;featureLayerSelectMany = new FeatureLayer(featureLayerSelectManyURL, {mode: FeatureLayer.MODE_SELECTION, outFields: ["*"]});&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Goodness only knows why defining the outFields makes as difference - but it does!&amp;nbsp; Only took the best part of a day ;o)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sarah.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 13:46:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-selectfeatures-only-displays-one/m-p/731678#M67805</guid>
      <dc:creator>SarahNoakes1</dc:creator>
      <dc:date>2015-05-26T13:46:38Z</dc:date>
    </item>
  </channel>
</rss>

