<?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: What is the best way to select features from multiple layers in 4.x? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-best-way-to-select-features-from/m-p/1076580#M73771</link>
    <description>&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;Have you tried this option, I need solution for similar task. Could you please share the idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jul 2021 01:52:10 GMT</pubDate>
    <dc:creator>jkumartry1980</dc:creator>
    <dc:date>2021-07-08T01:52:10Z</dc:date>
    <item>
      <title>What is the best way to select features from multiple layers in 4.x?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-best-way-to-select-features-from/m-p/1034020#M71964</link>
      <description>&lt;P&gt;I have a map that contains features services, map services and graphic layers. What is the best way to select multiple features from multiple layers? For example, I want a user to be able to select a point in a mass of features from multiple layers and cycle through the features in a custom side panel to find the feature they are interested in.&lt;/P&gt;&lt;P&gt;I tried using&amp;nbsp;&lt;STRONG&gt;hitTest&lt;/STRONG&gt;, but that only returns the first feature from each layer. Too bad.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found &lt;A href="https://developers.arcgis.com/javascript/3/jssamples/query_deferred_list.html" target="_self"&gt;this example&lt;/A&gt; for 3.x. Would this be the best approach in 4.x as well? Any chance I could get one of your awesome working codepen examples using 4.x?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Query&lt;/STRONG&gt; and &lt;STRONG&gt;QuertyTask&amp;nbsp;&lt;/STRONG&gt;are kind of pain because the buffer needs to change based on the zoom level. I know the API is already accounting for that using&amp;nbsp;&lt;STRONG&gt;hitTest&amp;nbsp;&lt;/STRONG&gt;and other methods. Are there any other approaches we should consider? For example, in 3.x, we used&amp;nbsp;&lt;STRONG&gt;var popup = map.infoWindow&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;connect.connect(popup, "onSetFeatures", function() {})&lt;/STRONG&gt; to trigger the custom panel based on a click on the map. Is there an equivalent approach in 4.x?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 17:16:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-best-way-to-select-features-from/m-p/1034020#M71964</guid>
      <dc:creator>MattStayner</dc:creator>
      <dc:date>2021-03-08T17:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to select features from multiple layers in 4.x?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-best-way-to-select-features-from/m-p/1034108#M71972</link>
      <description>&lt;P&gt;I wonder if this might help in your use-case:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#fetchFeatures" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#fetchFeatures&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/widgets-feature-multiplelayers/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/widgets-feature-multiplelayers/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 19:27:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-best-way-to-select-features-from/m-p/1034108#M71972</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2021-03-08T19:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to select features from multiple layers in 4.x?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-best-way-to-select-features-from/m-p/1034765#M71989</link>
      <description>&lt;P&gt;The Esri widget Popup looks like it is what we are looking for. We will give it a try. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 00:37:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-best-way-to-select-features-from/m-p/1034765#M71989</guid>
      <dc:creator>MattStayner</dc:creator>
      <dc:date>2021-03-10T00:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to select features from multiple layers in 4.x?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-best-way-to-select-features-from/m-p/1076580#M73771</link>
      <description>&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;Have you tried this option, I need solution for similar task. Could you please share the idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 01:52:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-best-way-to-select-features-from/m-p/1076580#M73771</guid>
      <dc:creator>jkumartry1980</dc:creator>
      <dc:date>2021-07-08T01:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to select features from multiple layers in 4.x?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-best-way-to-select-features-from/m-p/1076816#M73777</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/498753"&gt;@jkumartry1980&lt;/a&gt;&amp;nbsp;Yes, I got it working, but it took a bit to get everything in place.&lt;/P&gt;&lt;P&gt;First, I added the popupTemplate to all the feature layers in my map&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;layerToAdd = new FeatureLayer(layer.service_url, {
  outFields: ['*'],
  id: layerName,
  popupTemplate: {}, // required to trigger info panel
  visible
})&lt;/LI-CODE&gt;&lt;P&gt;Then I listened for a click on the view, and looked at all of the results:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.view.on('click', async (event) =&amp;gt; {
  // Use popup to select features on the map. Only features with popupTemplate enabled will be selected
  const resp = await view.popup.fetchFeatures(event)
  const results = await resp.allGraphicsPromise
  if (Array.isArray(results)) {
    if (results.length === 0) {
      this.$emit('pointer-clicked-outside')
      return
    }
    const popupResults = results.filter((r) =&amp;gt; {
      //do something with results, like highlight the selected feature
      await this.highlightItem(r)
    })
  }
})&lt;/LI-CODE&gt;&lt;P&gt;Lastly, I highlighted the selected graphic&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;async highlightItem (gisInfo) {
    const { view } = this
    if (gisInfo.layer) {
      const layerView = await view.whenLayerView(gisInfo.layer)
      const selected = layerView.highlight(gisInfo)
      this.highlightSelect.push(selected)
    } else if (gisInfo?.sourceLayer?.layer) {
      const layerView = await view.whenLayerView(
        gisInfo.sourceLayer.layer
      )
      const selected = layerView.highlight(gisInfo)
      this.highlightSelect.push(selected)
    }
}&lt;/LI-CODE&gt;&lt;P&gt;I stripped out the code that wasn't applicable. I'm not sure if what I have above will work exactly as-is, but hopefully it gets you on the right track.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 16:51:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-best-way-to-select-features-from/m-p/1076816#M73777</guid>
      <dc:creator>MattStayner</dc:creator>
      <dc:date>2021-07-08T16:51:21Z</dc:date>
    </item>
  </channel>
</rss>

