<?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 Get all features in extent in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-all-features-in-extent/m-p/1227672#M79206</link>
    <description>&lt;P&gt;Hi guys, I'd like to have a list displayed external to the webMap in my app that shows all features in the current extent. And then the user should be able to zoom/pan and have the list automatically update with only the features available in the new extent (after zooming/panning).&amp;nbsp;&lt;/P&gt;&lt;P&gt;See image to see the functionality I am trying to implement:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnAlien_0-1667335613692.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/55020iE04BFF9E52AB745E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AnAlien_0-1667335613692.png" alt="AnAlien_0-1667335613692.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The results of a search should be displayed on a map as well as the map being able to filter (as user drags/zooms).&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get a list of features that is dynamically tied to the extent?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2022 20:47:44 GMT</pubDate>
    <dc:creator>AnAlien</dc:creator>
    <dc:date>2022-11-01T20:47:44Z</dc:date>
    <item>
      <title>Get all features in extent</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-all-features-in-extent/m-p/1227672#M79206</link>
      <description>&lt;P&gt;Hi guys, I'd like to have a list displayed external to the webMap in my app that shows all features in the current extent. And then the user should be able to zoom/pan and have the list automatically update with only the features available in the new extent (after zooming/panning).&amp;nbsp;&lt;/P&gt;&lt;P&gt;See image to see the functionality I am trying to implement:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnAlien_0-1667335613692.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/55020iE04BFF9E52AB745E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AnAlien_0-1667335613692.png" alt="AnAlien_0-1667335613692.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The results of a search should be displayed on a map as well as the map being able to filter (as user drags/zooms).&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get a list of features that is dynamically tied to the extent?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 20:47:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-all-features-in-extent/m-p/1227672#M79206</guid>
      <dc:creator>AnAlien</dc:creator>
      <dc:date>2022-11-01T20:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Get all features in extent</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-all-features-in-extent/m-p/1328374#M82211</link>
      <description>&lt;P&gt;I know this is a late message, but you can achieve this by doing the following:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    const getAllLayerViews = mapView.map.allLayers.map(layer =&amp;gt; mapView.whenLayerView(layer));

    const layerViews = await Promise.all(getAllLayerViews);
    layerViews.forEach(layerView =&amp;gt; {
        // monitor layer loading status
        const watchUpdatesHandle = watch(
            () =&amp;gt; layerView.updating,
            updating =&amp;gt; {
                const layer = getLayerFromId(layerView.layer.id, layers);
                if (!layer) {
                    return;
                }
                controller.broadcast("layerLoadingStatus", {
                    layer: layer,
                    isLoading: updating
                });

                // if it finished loading, then broadcast visible features
                if (!updating &amp;amp;&amp;amp; isQueryable(layerView.layer)) {
                    const allQuery = new Query();
                    allQuery.geometry = mapView.extent;
                    allQuery.spatialRelationship = "intersects";
                    layerView.layer
                        .queryFeatures(allQuery)
                        .then(visibleFeatures =&amp;gt; {
                            controller.broadcast("visibleFeaturesChanged", {
                                layer: layer,
                                features: visibleFeatures
                            });
                        })
                        .catch(console.error);
                }
            }
        );

        // clean up when the layer is destructed
        layerView.addHandles(watchUpdatesHandle);
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;This snippet starts off by watching the loading status of all layers available on your webmap (using ESRI's `watch` utility - very useful and more resources about that here:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-reactiveUtils.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-core-reactiveUtils.html&lt;/A&gt;)&lt;BR /&gt;&lt;BR /&gt;Then once the layer is no longer loading, check if the `layer` supports the `queryFeatures` method, if it does, then we create a new filter which uses the extent/viewport of the map itself in the `Query`. Finally, broadcast these changes to your UI so that it informs you of what is currently visible in the map view.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 16:35:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-all-features-in-extent/m-p/1328374#M82211</guid>
      <dc:creator>IbrahimE</dc:creator>
      <dc:date>2023-09-13T16:35:21Z</dc:date>
    </item>
  </channel>
</rss>

