<?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 and export in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-and-export/m-p/1243596#M79724</link>
    <description>&lt;P&gt;JoelBennett is correct.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;map.allLayers.forEach(layer =&amp;gt; {
            // Query all layers data
			if (layer.type === "feature" &amp;amp;&amp;amp; layer.visible){
                layer.queryFeatures(query)
                .then((results) =&amp;gt; {
                    // do something with query results
                  console.log(results)
                })
                .catch(errorCallback);
				}
            });&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 23 Dec 2022 16:35:15 GMT</pubDate>
    <dc:creator>LefterisKoumis</dc:creator>
    <dc:date>2022-12-23T16:35:15Z</dc:date>
    <item>
      <title>Select multiple layers and export</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-and-export/m-p/1243550#M79720</link>
      <description>&lt;P&gt;Hi Guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;On my map i want to select multiple layers by drawing rectangle and than export selected features fields. i have this code thanks to&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/191789"&gt;@BlakeTerhune&lt;/a&gt;&amp;nbsp; &amp;nbsp;(From my previous&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-with-polygon/m-p/1146480#M76426" target="_blank" rel="noopener"&gt; topic&lt;/A&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&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;// create a new sketch view model set its layer
        const sketchViewModell = new SketchViewModel({
          view: view,
          layer: polygonGraphicsLayerr
        });
        // Once user is done drawing a rectangle on the map
        // use the rectangle to select features on the map and table
        sketchViewModell.on("create", async (event) =&amp;gt; {
          if (event.state === "complete") {
            // this polygon will be used to query features that intersect it
            const geometriess = polygonGraphicsLayerr.graphics.map(function(graphic){
              return graphic.geometry
            });
            const queryGeometry = await geometryEngineAsync.union(geometriess.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) {
            // create a query and set its geometry parameter to the
            // rectangle that was drawn on the view
            var query = {
              geometry: geometry,
              outFields: ["*"]
            };
            
            map.allLayers.forEach(layer =&amp;gt; {
            // Query all layers data
                layer.queryFeatures(query)
                .then((results) =&amp;gt; {
                    // do something with query results
                  console.log(results)
                })
                .catch(errorCallback);
            });
        };&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;&lt;/P&gt;&lt;P&gt;When i draw rectangle in logs i get error:&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;layer.queryFeatures is not a function;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;what i do wrong? What is wrong here and i can not see? Help&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 11:20:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-and-export/m-p/1243550#M79720</guid>
      <dc:creator>Vakhtang_Zubiashvili</dc:creator>
      <dc:date>2022-12-23T11:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Select multiple layers and export</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-and-export/m-p/1243595#M79723</link>
      <description>&lt;P&gt;Your code is assuming that all layers in your map are FeatureLayers, but that is unlikely.&amp;nbsp; You should therefore check the layer type before trying to execute a query on it.&amp;nbsp; One simple check would be like so:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;map.allLayers.forEach(layer =&amp;gt; {
	// Query all layers data
	if (typeof layer.queryFeatures == "function") {
		layer.queryFeatures(query).then((results) =&amp;gt; {
			// do something with query results
			console.log(results)
		}).catch(errorCallback);
	}
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 16:23:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-and-export/m-p/1243595#M79723</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2022-12-23T16:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Select multiple layers and export</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-and-export/m-p/1243596#M79724</link>
      <description>&lt;P&gt;JoelBennett is correct.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;map.allLayers.forEach(layer =&amp;gt; {
            // Query all layers data
			if (layer.type === "feature" &amp;amp;&amp;amp; layer.visible){
                layer.queryFeatures(query)
                .then((results) =&amp;gt; {
                    // do something with query results
                  console.log(results)
                })
                .catch(errorCallback);
				}
            });&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 23 Dec 2022 16:35:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-and-export/m-p/1243596#M79724</guid>
      <dc:creator>LefterisKoumis</dc:creator>
      <dc:date>2022-12-23T16:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Select multiple layers and export</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-and-export/m-p/1243659#M79729</link>
      <description>&lt;P&gt;Thank You guys&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/6522"&gt;@JoelBennett&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/14521"&gt;@LefterisKoumis&lt;/a&gt;&amp;nbsp;, both code works fine, simply checking layer type &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Thanks again for help.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Dec 2022 19:53:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-multiple-layers-and-export/m-p/1243659#M79729</guid>
      <dc:creator>Vakhtang_Zubiashvili</dc:creator>
      <dc:date>2022-12-24T19:53:06Z</dc:date>
    </item>
  </channel>
</rss>

