<?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 Geometry returned from hitTest() throws &amp;quot;Invalid query parameters&amp;quot; when used as query geometry in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-returned-from-hittest-throws-quot-invalid/m-p/1008869#M71092</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;Intended effect&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;When user clicks on view, hitTest() returns geometry from visible polygons that are to be used in a query by location on localitiesLayer (point features). Code snippet and photo below to demonstrate desired behavior.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.on("click", function(event) {
  selectFeaturesFromClick(event);
});

function selectFeaturesFromClick(clickEvent) {
  var includeLayers = [countiesLayer, neighborhoodsLayer, regionsLayer, 
                       clientFeatureLayer]
view.hitTest(clickEvent, {include: includeLayers}).then(function(response) {
  if (response.results.length &amp;gt; 0) {
    selectFeatures(clickFeature);
  }
});

function selectFeatures(feature) {
  var geometry = feature.geometry;
  var query = {
    geometry: geometry,
    spatialRelationship: "intersects",
    outFields: ["*"], 
    returnGeometry: true
  };
  localitiesLayer.queryFeatures(query).then(function(results) {
    ...
  });
});&lt;/LI-CODE&gt;&lt;P&gt;[Image of app with desired behavior (Riverside)]: &lt;A href="https://i.stack.imgur.com/BIQrN.png" target="_blank"&gt;https://i.stack.imgur.com/BIQrN.png&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;Issue&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;When certain features from the hosted feature layer countiesLayer are clicked, the query request cannot be completed with the following error message: "Cannot perform query. Invalid query parameters".&lt;/P&gt;&lt;P&gt;For whatever reason, this seems to occur with most of the features but not with all of them. As shown with the photo above, it works as intended when "Riverside" is clicked but not "Los Angeles" as shown in the image below.&lt;/P&gt;&lt;P&gt;[Image of app displaying bug (Los Angeles]: &lt;A href="https://i.stack.imgur.com/Rj80G.png" target="_blank"&gt;https://i.stack.imgur.com/Rj80G.png&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;Troubleshooting&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;At first I thought it might have something to do with the localityLayer being not loaded at the time of the .query(), but that wouldn't account for the other feature layers working just fine.&lt;/P&gt;&lt;P&gt;I can't seem to figure out what would be different in the features that do seem to work and those that don't. The other feature layers included in the hit test seem to work as expected.&lt;/P&gt;&lt;P&gt;When a LayerView of the localitiesLayer is used for the query, the app works as intended. However I would rather not have to continuously update the a LayerView as it seems to impact performance when users are constantly panning/zooming around the map. And furthermore, I have had issues querying all fields from a LayerView.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;Question&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Is this specifically related to the way that I have written the hitTest()?&lt;BR /&gt;I've included a link to a CodePen with the app for anyone who would like to take a look.&lt;/P&gt;&lt;P&gt;[CodePen of app with bug]: &lt;A href="https://codepen.io/dmarkbreiter/pen/BaLLOmq" target="_blank"&gt;https://codepen.io/dmarkbreiter/pen/BaLLOmq&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Dec 2020 15:49:29 GMT</pubDate>
    <dc:creator>dmarkbreiter</dc:creator>
    <dc:date>2020-12-11T15:49:29Z</dc:date>
    <item>
      <title>Geometry returned from hitTest() throws "Invalid query parameters" when used as query geometry</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-returned-from-hittest-throws-quot-invalid/m-p/1008869#M71092</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;Intended effect&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;When user clicks on view, hitTest() returns geometry from visible polygons that are to be used in a query by location on localitiesLayer (point features). Code snippet and photo below to demonstrate desired behavior.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.on("click", function(event) {
  selectFeaturesFromClick(event);
});

function selectFeaturesFromClick(clickEvent) {
  var includeLayers = [countiesLayer, neighborhoodsLayer, regionsLayer, 
                       clientFeatureLayer]
view.hitTest(clickEvent, {include: includeLayers}).then(function(response) {
  if (response.results.length &amp;gt; 0) {
    selectFeatures(clickFeature);
  }
});

function selectFeatures(feature) {
  var geometry = feature.geometry;
  var query = {
    geometry: geometry,
    spatialRelationship: "intersects",
    outFields: ["*"], 
    returnGeometry: true
  };
  localitiesLayer.queryFeatures(query).then(function(results) {
    ...
  });
});&lt;/LI-CODE&gt;&lt;P&gt;[Image of app with desired behavior (Riverside)]: &lt;A href="https://i.stack.imgur.com/BIQrN.png" target="_blank"&gt;https://i.stack.imgur.com/BIQrN.png&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;Issue&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;When certain features from the hosted feature layer countiesLayer are clicked, the query request cannot be completed with the following error message: "Cannot perform query. Invalid query parameters".&lt;/P&gt;&lt;P&gt;For whatever reason, this seems to occur with most of the features but not with all of them. As shown with the photo above, it works as intended when "Riverside" is clicked but not "Los Angeles" as shown in the image below.&lt;/P&gt;&lt;P&gt;[Image of app displaying bug (Los Angeles]: &lt;A href="https://i.stack.imgur.com/Rj80G.png" target="_blank"&gt;https://i.stack.imgur.com/Rj80G.png&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;Troubleshooting&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;At first I thought it might have something to do with the localityLayer being not loaded at the time of the .query(), but that wouldn't account for the other feature layers working just fine.&lt;/P&gt;&lt;P&gt;I can't seem to figure out what would be different in the features that do seem to work and those that don't. The other feature layers included in the hit test seem to work as expected.&lt;/P&gt;&lt;P&gt;When a LayerView of the localitiesLayer is used for the query, the app works as intended. However I would rather not have to continuously update the a LayerView as it seems to impact performance when users are constantly panning/zooming around the map. And furthermore, I have had issues querying all fields from a LayerView.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;Question&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Is this specifically related to the way that I have written the hitTest()?&lt;BR /&gt;I've included a link to a CodePen with the app for anyone who would like to take a look.&lt;/P&gt;&lt;P&gt;[CodePen of app with bug]: &lt;A href="https://codepen.io/dmarkbreiter/pen/BaLLOmq" target="_blank"&gt;https://codepen.io/dmarkbreiter/pen/BaLLOmq&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 15:49:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-returned-from-hittest-throws-quot-invalid/m-p/1008869#M71092</guid>
      <dc:creator>dmarkbreiter</dc:creator>
      <dc:date>2020-12-11T15:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry returned from hitTest() throws "Invalid query parameters" when used as query geometry</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-returned-from-hittest-throws-quot-invalid/m-p/1009052#M71095</link>
      <description>&lt;P&gt;Try simplifying the geometry:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// simplification distance can be static based on your data
// or dynamic based on current view scale or other relevant context
var geometry = geometryEngine.simplify(polygon.geometry, 1000);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 23:13:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-returned-from-hittest-throws-quot-invalid/m-p/1009052#M71095</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2020-12-11T23:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry returned from hitTest() throws "Invalid query parameters" when used as query geometry</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-returned-from-hittest-throws-quot-invalid/m-p/1009234#M71099</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Thank you so much for the help!&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;That seems to have solved the problem I asked about. If you don't mind, can you explain a little further as to why this approach works? What about the feature geometry was not legal and causing the error?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Also, I have marked this answer as a solution to the accompanying &lt;A href="https://stackoverflow.com/questions/65227588/geometry-returned-from-hittest-throws-invalid-query-parameters-when-used-as/65286649#65286649" target="_self"&gt;StackOverflow post&lt;/A&gt;&amp;nbsp;, with a link to your profile.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 09:41:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-returned-from-hittest-throws-quot-invalid/m-p/1009234#M71099</guid>
      <dc:creator>dmarkbreiter</dc:creator>
      <dc:date>2020-12-14T09:41:15Z</dc:date>
    </item>
  </channel>
</rss>

