<?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 queryFeatures method does not work on a client-side FeatureLayer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-method-does-not-work-on-a-client/m-p/1262180#M80397</link>
    <description>&lt;P&gt;I am trying to query, by geometry, a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html" target="_self"&gt;FeatureLayer&lt;/A&gt;. The Feature layer is a "client-side" Feature layer-- its created from a bunch of graphics added to its `source` property. When I call the `queryFeatures` or `queryObjectIds` method to get features within an overlapping extent or shape I never get any results back.&amp;nbsp;&lt;/P&gt;&lt;P&gt;H&lt;A href="https://codepen.io/ryansutc-the-flexboxer/pen/abaBgRw?editors=0011" target="_self"&gt;ere is a codepen&lt;/A&gt; demonstrating the problem. The below code snippet shows my approach:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let graphics = [
            new Graphic({
              attributes: {
                ogc_fid: 1,
                val: "one"
              },
              geometry: new Point({
                latitude: 44.99,
                longitude: -68.99,
                spatialReference: {latestWkid: 4326, wkid: 4326}
              })
            }),
            new Graphic({
              attributes: {
                ogc_fid: 2,
                val: "two"
              },
              geometry: new Point({
                latitude: 44.98,
                longitude: -68.98,
                spatialReference: {latestWkid: 4326, wkid: 4326}
              })
            }),
          ]
          let myLayer = new FeatureLayer({
            source: graphics,
            objectIdField: "ogc_fid",
            fields: [{
              name: "ogc_fid",
              type: "oid"
            }, {
              name: "val",
              type: "string"
            }],
            renderer: {
               symbol: {
                 color: "red",
                 size: 6,
                 type: "simple-marker",
               },
              // overrides the layer's default renderer
              type: "simple",
            }
          });
// .....
 // try to query client-side featureLayer by an extent:
          let extent = new Extent({
            spatialReference: { wkid: 4326},
            xmax: 45.5,
            xmin: 44.7,
            ymax: -68.5,
            ymin: -69.5
          })
         myLayer.queryObjectIds({
           geometry: extent,
           spatialRelationship: "intersects",
           //there are no features returned
         }).then(result =&amp;gt;  console.log(result))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above will return no results. I can get results via an attribute query but geometry-ones all return nothing. Can anyone spot what I am doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H5&gt;What I've tried:&lt;/H5&gt;&lt;P&gt;I've looked at other posts&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-kind-of-query-does-queryfeatures-support/m-p/727494" target="_self"&gt; like this one&lt;/A&gt; where Robert's approach looks about the same as mine, besides him creating a special Query object. I've been able to get similar to above to work on a FeatureLayer based on a featureService (aka: url property).&lt;/P&gt;&lt;P&gt;As shown in the CodePen, I've also tried running the queries on the &lt;STRONG&gt;FeatureLayerView.&lt;/STRONG&gt;&amp;nbsp;Interestingly, no results return there under any circumstance which is also unexpected.. bonus points if you can explain that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Feb 2023 22:00:43 GMT</pubDate>
    <dc:creator>RyanSutcliffe</dc:creator>
    <dc:date>2023-02-27T22:00:43Z</dc:date>
    <item>
      <title>queryFeatures method does not work on a client-side FeatureLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-method-does-not-work-on-a-client/m-p/1262180#M80397</link>
      <description>&lt;P&gt;I am trying to query, by geometry, a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html" target="_self"&gt;FeatureLayer&lt;/A&gt;. The Feature layer is a "client-side" Feature layer-- its created from a bunch of graphics added to its `source` property. When I call the `queryFeatures` or `queryObjectIds` method to get features within an overlapping extent or shape I never get any results back.&amp;nbsp;&lt;/P&gt;&lt;P&gt;H&lt;A href="https://codepen.io/ryansutc-the-flexboxer/pen/abaBgRw?editors=0011" target="_self"&gt;ere is a codepen&lt;/A&gt; demonstrating the problem. The below code snippet shows my approach:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let graphics = [
            new Graphic({
              attributes: {
                ogc_fid: 1,
                val: "one"
              },
              geometry: new Point({
                latitude: 44.99,
                longitude: -68.99,
                spatialReference: {latestWkid: 4326, wkid: 4326}
              })
            }),
            new Graphic({
              attributes: {
                ogc_fid: 2,
                val: "two"
              },
              geometry: new Point({
                latitude: 44.98,
                longitude: -68.98,
                spatialReference: {latestWkid: 4326, wkid: 4326}
              })
            }),
          ]
          let myLayer = new FeatureLayer({
            source: graphics,
            objectIdField: "ogc_fid",
            fields: [{
              name: "ogc_fid",
              type: "oid"
            }, {
              name: "val",
              type: "string"
            }],
            renderer: {
               symbol: {
                 color: "red",
                 size: 6,
                 type: "simple-marker",
               },
              // overrides the layer's default renderer
              type: "simple",
            }
          });
// .....
 // try to query client-side featureLayer by an extent:
          let extent = new Extent({
            spatialReference: { wkid: 4326},
            xmax: 45.5,
            xmin: 44.7,
            ymax: -68.5,
            ymin: -69.5
          })
         myLayer.queryObjectIds({
           geometry: extent,
           spatialRelationship: "intersects",
           //there are no features returned
         }).then(result =&amp;gt;  console.log(result))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above will return no results. I can get results via an attribute query but geometry-ones all return nothing. Can anyone spot what I am doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H5&gt;What I've tried:&lt;/H5&gt;&lt;P&gt;I've looked at other posts&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-kind-of-query-does-queryfeatures-support/m-p/727494" target="_self"&gt; like this one&lt;/A&gt; where Robert's approach looks about the same as mine, besides him creating a special Query object. I've been able to get similar to above to work on a FeatureLayer based on a featureService (aka: url property).&lt;/P&gt;&lt;P&gt;As shown in the CodePen, I've also tried running the queries on the &lt;STRONG&gt;FeatureLayerView.&lt;/STRONG&gt;&amp;nbsp;Interestingly, no results return there under any circumstance which is also unexpected.. bonus points if you can explain that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 22:00:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-method-does-not-work-on-a-client/m-p/1262180#M80397</guid>
      <dc:creator>RyanSutcliffe</dc:creator>
      <dc:date>2023-02-27T22:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: queryFeatures method does not work on a client-side FeatureLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-method-does-not-work-on-a-client/m-p/1262192#M80400</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Several things going on in your codepen.&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, your polygon geometry does not intersect with the points. You have the x and ys reversed. If you update that then the layer.queryFeatures will return the correct results. However the layerView will still return empty array because you are running the layerView query when the app loads. In this case you have to wait until the layerView is done updating.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I updated your codepen to reflect the changes I mentioned above:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/GRXrKJq?editors=0011" target="_blank" rel="noopener"&gt;https://codepen.io/U_B_U/pen/GRXrKJq?editors=0011&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 22:27:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-method-does-not-work-on-a-client/m-p/1262192#M80400</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2023-02-27T22:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: queryFeatures method does not work on a client-side FeatureLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-method-does-not-work-on-a-client/m-p/1262206#M80401</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;for the prompt response. I am embarrassed that I missed the issue with the extent's coordinates. Thank you for catching that obvious error. I was also not aware (or had forgotten) that a layerView's queryFeatures request will only work after the features are completely drawn in the map and its own state is not set to 'updating'.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 23:22:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-method-does-not-work-on-a-client/m-p/1262206#M80401</guid>
      <dc:creator>RyanSutcliffe</dc:creator>
      <dc:date>2023-02-27T23:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: queryFeatures method does not work on a client-side FeatureLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-method-does-not-work-on-a-client/m-p/1262236#M80402</link>
      <description>&lt;P&gt;No worries at all. Happens to all of us.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 00:18:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-method-does-not-work-on-a-client/m-p/1262236#M80402</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2023-02-28T00:18:03Z</dc:date>
    </item>
  </channel>
</rss>

