<?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: Select multiple layers with polygon in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-with-polygon/m-p/1146480#M76426</link>
    <description>&lt;P&gt;Glad you got it figured out,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/107000"&gt;@Vakhtang_Zubiashvili&lt;/a&gt;. Can you post the solution to help other people with a similar problem?&lt;/P&gt;</description>
    <pubDate>Tue, 22 Feb 2022 14:59:48 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2022-02-22T14:59:48Z</dc:date>
    <item>
      <title>Select multiple layers with polygon</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-with-polygon/m-p/1143983#M76351</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I have four layers ( names: csvLayer, csvLayer1, csvLayer2, csvLayer3) on my map which have same fields and i have custom html table where i add features selected on map using polygon, but i can add features only from one layer, which is selected in code. In this code i can path one layer, but how can i path all four layers to select features from them? Here is code i use for selecting fatures:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let features = [];
        let csvLayerView;
        csvLayer.when(() =&amp;gt; {
          view.whenLayerView(csvLayer).then(function (layerView) {
            csvLayerView = layerView;
          });
        })
        .catch(errorCallback);
        // polygonGraphicsLayer will be used by the sketchviewmodel
        // show the polygon being drawn on the view
        const polygonGraphicsLayer = new GraphicsLayer();
        map.add(polygonGraphicsLayer);
        // add the select by rectangle button the view
        //view.ui.add("select-by-rectangle", "top-left");
        const selectButton = document.getElementById("select-by-rectangle");
        // click event for the select by rectangle button
        selectButton.addEventListener("click", () =&amp;gt; {
          view.popup.close();
          sketchViewModel.create("polygon");
        }); 
        // add the clear selection button the view
        //view.ui.add("clear-selection", "top-left");
        //document.getElementById("clear-selection").addEventListener("click", () =&amp;gt; {
          //featureTable.clearSelection();
          //featureTable.filterGeometry = null;
          //polygonGraphicsLayer.removeAll();
        //});
        // create a new sketch view model set its layer
        const sketchViewModel = new SketchViewModel({
          view: view,
          layer: polygonGraphicsLayer
        });
        // Once user is done drawing a rectangle on the map
        // use the rectangle to select features on the map and table
        sketchViewModel.on("create", async (event) =&amp;gt; {
          if (event.state === "complete") {
            // this polygon will be used to query features that intersect it
            const geometries = polygonGraphicsLayer.graphics.map(function(graphic){
              return graphic.geometry
            });
            const queryGeometry = await geometryEngineAsync.union(geometries.toArray());
            selectFeatures(queryGeometry);
          }
        });
        // This function is called when user completes drawing a rectangle
        // on the map. Use the rectangle to select features in the layer and table
        function selectFeatures(geometry) {
          if (csvLayerView) {
            // create a query and set its geometry parameter to the
            // rectangle that was drawn on the view
            const query = {
              geometry: geometry,
              outFields: ["*"]
            };
            // query graphics from the csv layer view. Geometry set for the query
            // can be polygon for point features and only intersecting geometries are returned
            csvLayerView.queryFeatures(query)
              .then((results) =&amp;gt; {
                //const raro = [];
                if (results.features.length === 0) {
                  clearSelection();
                } else {
                  // მონიშნული ობიექტებისთვის მონაცემების წამოღება და ცხრილში ასახვა 
                  results.features.forEach((feature)=&amp;gt;{
                    var tablemili = document.getElementById("tablemili");
                    newRow = tablemili.insertRow(tablemili.length),
                    cell1 = newRow.insertCell(0),
                    cell2 = newRow.insertCell(1),
                    cell3 = newRow.insertCell(2),
                    cell4 = newRow.insertCell(3),
                    cell5 = newRow.insertCell(4),
                    cell1.innerHTML = feature.attributes["milis_ID"]; 
                    cell2.innerHTML = feature.attributes["diametri"]; 
                    cell3.innerHTML = feature.attributes["dasaxeleba"]; 
                    cell4.innerHTML = feature.attributes["masala"]; 
                    cell5.innerHTML = feature.attributes["qselis_kategoria"]; 
                    });  
                  polygonGraphicsLayer.removeAll();
                }
              })
              .catch(errorCallback);
          }
        }
        function errorCallback(error) {
          console.log("error happened:", error.message);
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 15 Feb 2022 10:13:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-with-polygon/m-p/1143983#M76351</guid>
      <dc:creator>Vakhtang_Zubiashvili</dc:creator>
      <dc:date>2022-02-15T10:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select multiple layers with polygon</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-with-polygon/m-p/1144036#M76356</link>
      <description>&lt;P&gt;Sorry if I'm misunderstanding, but can you loop over all your layers to do the query on line 57 in&amp;nbsp;selectFeatures()?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;map.allLayers.forEach(layer =&amp;gt; {
    // query graphics from the csv layer view. Geometry set for the query
    // can be polygon for point features and only intersecting geometries are returned
    layer.queryFeatures(query)
    .then((results) =&amp;gt; {
        // do something with query results
    })
    .catch(errorCallback);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 14:28:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-with-polygon/m-p/1144036#M76356</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-02-15T14:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Select multiple layers with polygon</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-with-polygon/m-p/1146085#M76410</link>
      <description>&lt;P&gt;Thanks, but it does not work form me. I took another way to solve my issue. Thanks again.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Feb 2022 07:41:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-with-polygon/m-p/1146085#M76410</guid>
      <dc:creator>Vakhtang_Zubiashvili</dc:creator>
      <dc:date>2022-02-21T07:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Select multiple layers with polygon</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-with-polygon/m-p/1146480#M76426</link>
      <description>&lt;P&gt;Glad you got it figured out,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/107000"&gt;@Vakhtang_Zubiashvili&lt;/a&gt;. Can you post the solution to help other people with a similar problem?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Feb 2022 14:59:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-with-polygon/m-p/1146480#M76426</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-02-22T14:59:48Z</dc:date>
    </item>
  </channel>
</rss>

