ArcGIS JS API v3.22 Query features does not respect returnGeometry

374
1
01-10-2018 08:47 AM
DonWaldo
New Contributor II

When using the API to call back to ArcGIS Server 10.41, geometries are always returned irregardless of the returnGeometry flag.

Snippet

private getGisDataQuery(field: string, value: string): Query {     let query = new Query();     query.returnGeometry = false;     query.outFields = ["*"];     query.where = `${field}='${value}'`;     return query;}

I found this question which may be related?  https://community.esri.com/thread/203730-queryparameters-returngeometry-not-honored  

If so it would mean this is more of a service, or server issue, not necessarily a bug with the API.

0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus

Don,

   Here is a sample that use JS API 3.22 and a 10.4.1 ArcGIS Server service and does not display the issue you are reporting:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Query State Info without Map</title>

    <script src="https://js.arcgis.com/3.22/"></script>
    <script>
      require([
        "dojo/dom", "dojo/on",
        "esri/tasks/query", "esri/tasks/QueryTask", "dojo/domReady!"
      ], function (dom, on, Query, QueryTask) {

        var queryTask = new QueryTask("https://sampleserver6.arcgisonline.com/ArcGIS/rest/services/Census/MapServer/3");

        var query = new Query();
        query.returnGeometry = false;
        query.outFields = ["*"];

        on(dom.byId("execute"), "click", execute);

        function execute () {
          query.text = dom.byId("stateName").value;
          queryTask.execute(query, showResults);
        }

        function showResults (results) {
          console.info(results)
          var resultItems = [];
          var resultCount = results.features.length;
          for (var i = 0; i < resultCount; i++) {
            var featureAttributes = results.features[i].attributes;
            for (var attr in featureAttributes) {
              resultItems.push("<b>" + attr + ":</b>  " + featureAttributes[attr] + "<br>");
            }
            resultItems.push("<br>");
          }
          dom.byId("info").innerHTML = resultItems.join("");
        }
      });
    </script>
  </head>

  <body>
    US state name :
    <input type="text" id="stateName" value="California">
    <input id="execute" type="button" value="Get Details">
    <br />
    <br />
    <div id="info" style="padding:5px; margin:5px; background-color:#eee;">
    </div>
  </body>
</html>
0 Kudos