<?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: Automatic popup of only the visible features in a webmap after a spatial filter has been executed in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-popup-of-only-the-visible-features-in-a/m-p/1375991#M83489</link>
    <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I updated the &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=widgets-features" target="_self"&gt;features widget sample&lt;/A&gt;&amp;nbsp;to allow users select features from a layer using a rectangle user draws on the map and display the popup info in Features widget. Hope you can use as a starting point: &lt;A href="https://codepen.io/U_B_U/pen/JjzpNjx?editors=1000" target="_blank"&gt;https://codepen.io/U_B_U/pen/JjzpNjx?editors=1000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The main part to pay attention to is the following, where you query the features from the layer view once user provides the spatial geometry. Then to pass the filtered features to &amp;nbsp;the Features widget's features property when calling its open method.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;layerView.queryFeatures(query).then((results) =&amp;gt; {
  if (results.features.length === 0) {
    return;
   } else {
     featuresWidget.open({
       location: event.mapPoint,
       features: results.features
     });
   }
 });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jan 2024 17:01:18 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2024-01-30T17:01:18Z</dc:date>
    <item>
      <title>Automatic popup of only the visible features in a webmap after a spatial filter has been executed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-popup-of-only-the-visible-features-in-a/m-p/1375884#M83488</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm struggling to implement a pop-up in my app which shows the features of a webmap which have been filtered in a spatial query via a geometry (i.e. point, line, polgon.)&lt;/P&gt;&lt;P&gt;I wanted to ask whether it is possible to implement a pop-up in this way, or whether I would have to keep things simple and select only a point within a geometry, such as the centroid in this example? &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/featurelayerview-query/" target="_self"&gt;https://developers.arcgis.com/javascript/latest/sample-code/featurelayerview-query/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.openPopup({
  features: [result],
  location: result.geometry.centroid
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I know that in examples like this, you can produce a pop-up via a click:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=widgets-feature-multiplelayers" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=widgets-feature-multiplelayers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The way my app works is that a sketch geometry, 'filterGeometry' is generated and then used alongside a spatial relationship (e.g. 'intersect') to filter a view of all the layers in the webmap, called 'featureLayerView.' This results in 'featureFilter.'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;        // set the geometry filter on the visible FeatureLayerView
        function updateFilter() {
          updateFilterGeometry();
          const featureFilter = {
            // autocasts to FeatureFilter
            geometry: filterGeometry,
            spatialRelationship: selectedFilter
          };

          featureLayerView.forEach((featureLayerView) =&amp;gt; {
            if (featureLayerViewFilterSelected) { //If true
                featureLayerView.visible = true; //Set the layers to visible
              featureLayerView.filter = featureFilter; //filter the features
                       } else {
              featureLayerView.filter = null;//else nothing
            }
        }); 
      };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would it be possible to enable a pop-up to automatically show after the sketch geometry has been drawn and the features have been filtered? (i.e. after the UpdateFilters() function has run.)&lt;/P&gt;&lt;P&gt;I'm still very new to app development, so any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 12:47:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-popup-of-only-the-visible-features-in-a/m-p/1375884#M83488</guid>
      <dc:creator>EmilyGoldsmith</dc:creator>
      <dc:date>2024-01-30T12:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic popup of only the visible features in a webmap after a spatial filter has been executed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-popup-of-only-the-visible-features-in-a/m-p/1375991#M83489</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I updated the &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=widgets-features" target="_self"&gt;features widget sample&lt;/A&gt;&amp;nbsp;to allow users select features from a layer using a rectangle user draws on the map and display the popup info in Features widget. Hope you can use as a starting point: &lt;A href="https://codepen.io/U_B_U/pen/JjzpNjx?editors=1000" target="_blank"&gt;https://codepen.io/U_B_U/pen/JjzpNjx?editors=1000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The main part to pay attention to is the following, where you query the features from the layer view once user provides the spatial geometry. Then to pass the filtered features to &amp;nbsp;the Features widget's features property when calling its open method.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;layerView.queryFeatures(query).then((results) =&amp;gt; {
  if (results.features.length === 0) {
    return;
   } else {
     featuresWidget.open({
       location: event.mapPoint,
       features: results.features
     });
   }
 });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 17:01:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-popup-of-only-the-visible-features-in-a/m-p/1375991#M83489</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2024-01-30T17:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic popup of only the visible features in a webmap after a spatial filter has been executed</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-popup-of-only-the-visible-features-in-a/m-p/1379765#M83605</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Many thanks for your reply and sorry for the delay in mine. This project has fallen to the wayside but I am still determined to figure it out.&lt;/P&gt;&lt;P&gt;Your edit of the features widget sample was very useful in helping me understand how I could implement something similar in my app. I believe i'm nearly there, I just need to figure out how to compile the pop-up details for each layer in the webmap's view into one pop-up. Currently, only the pop-up for the first layer appears as I have not configured it properly.&lt;/P&gt;&lt;P&gt;Here the code i've used so far to enable the pop-up to show upon drawing:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; // set the geometry filter on the visible FeatureLayerView
        function updateFilter() {
          updateFilterGeometry();
          const featureFilter = {
            // autocasts to FeatureFilter
            geometry: filterGeometry,
            spatialRelationship: selectedFilter
          };

          const query = {
            geometry: filterGeometry,
            outFields: ["*"]
          };

          featureLayerView.forEach((featureLayerView) =&amp;gt; {
            if (featureLayerViewFilterSelected) { //If true
                featureLayerView.visible = true; //Set the layers to visible
              featureLayerView.filter = featureFilter; //filter the features
          
              featureLayerView.queryFeatures(query)
              .then((results) =&amp;gt; {
                  if (results.features.length === 0) {
                    return;
                  } else {
                  view.openPopup({
                      location: filterGeometry,
                      features: results.features
                    });}})
                       } else {
                        
              featureLayerView.filter = null;//else nothing
            }&lt;/LI-CODE&gt;&lt;P&gt;Do you know if it is possible to 'push' information from multiple layers into one pop-up? Or if a custom popuptemplate would be required for this functionality?&amp;nbsp;&lt;/P&gt;&lt;P&gt;To outline, this app is based upon the 'Filter SceneLayer with FeatureFilter' example which filters the view of features by a selected spatial relationship according to the geometry of the sketch drawn by the user: &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/layers-scenelayer-feature-masking/" target="_self"&gt;https://developers.arcgis.com/javascript/latest/sample-code/layers-scenelayer-feature-masking/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Many thanks again for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 16:22:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-popup-of-only-the-visible-features-in-a/m-p/1379765#M83605</guid>
      <dc:creator>EmilyGoldsmith</dc:creator>
      <dc:date>2024-02-08T16:22:42Z</dc:date>
    </item>
  </channel>
</rss>

