<?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: Zooming to query result extent in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73622#M6653</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having problems with this too, especially in IE 8, which is still our version for IE.&amp;nbsp; In the code&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var selExtent = graphicsUtils.graphicsExtent(featureSet.features);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the variable selExtent is not found, it returns null.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There are features in my featureSet, which is a result of a queryTask.&amp;nbsp;&amp;nbsp; This works just fine in Firefox, but not in either Chrome or IE.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 22:51:44 GMT</pubDate>
    <dc:creator>TracySchloss</dc:creator>
    <dc:date>2021-12-10T22:51:44Z</dc:date>
    <item>
      <title>Zooming to query result extent</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73618#M6649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to zoom to the extent of a query I have.&amp;nbsp; I am having a problem when I call esri.graphicsUtils.graphicsExtent(resultFeatures) to get the extent.&amp;nbsp; It is returning NaN.&amp;nbsp; It works for one query I have that returns 42 records but for all the other queries I have it doesn't work.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTask.execute(query, function (featureSet) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var resultFeatures = featureSet.features;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var myFeatureExtent = esri.graphicsUtils.graphicsExtent(resultFeatures);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(myFeatureExtent); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var layerDefinitions = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerDefinitions[0] = queryString;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //siteslayer.setLayerDefinitions(layerDefinitions);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 21:21:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73618#M6649</guid>
      <dc:creator>SteveMacLean</dc:creator>
      <dc:date>2014-02-14T21:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Zooming to query result extent</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73619#M6650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try something along these lines, using &lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/jsapi/extent-amd.html#union" rel="nofollow noopener noreferrer" target="_blank"&gt;union&lt;/A&gt;&lt;SPAN&gt; to grow the extent to encompass all features:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var extent = featureSet.features[0].geometry.getExtent();
for (var i = 1; i &amp;lt; featureSet.features.length; i++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; extent = extent.union(featureSet.features&lt;I&gt;.geometry.getExtent());
}
&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:51:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73619#M6650</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2021-12-10T22:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Zooming to query result extent</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73620#M6651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;graphicsUtils.graphicsExtent is a lot faster than union for this purpose, especially when you are dealing with a large number of features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your code looks fine, all that could be wrong is your query, if you have forgot to set returnGeometry = true.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 07:29:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73620#M6651</guid>
      <dc:creator>JohnathanBarclay</dc:creator>
      <dc:date>2014-02-17T07:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Zooming to query result extent</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73621#M6652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;First of all, try to see if your query parameters and layers are correct,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, see what the returned featureSet object is, especially if the features have proper geometries and spatial reference.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 20:14:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73621#M6652</guid>
      <dc:creator>ZachLiu1</dc:creator>
      <dc:date>2014-02-17T20:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: Zooming to query result extent</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73622#M6653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having problems with this too, especially in IE 8, which is still our version for IE.&amp;nbsp; In the code&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var selExtent = graphicsUtils.graphicsExtent(featureSet.features);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the variable selExtent is not found, it returns null.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There are features in my featureSet, which is a result of a queryTask.&amp;nbsp;&amp;nbsp; This works just fine in Firefox, but not in either Chrome or IE.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:51:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73622#M6653</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2021-12-10T22:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Zooming to query result extent</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73623#M6654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm mistaken, it doesn't work properly in Firefox either.&amp;nbsp; It seems to be moving to the general vicinity of my featureSet, but it isn't set to the extent.&amp;nbsp; Instead, if I zoom out several times manually, I can see the points.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm wondering of the features returned as the results of a queryTask are the same as the results of a selectFeatures on a featureLayer.&amp;nbsp; Both say they are a featureSet.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2014 12:32:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73623#M6654</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2014-03-17T12:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Zooming to query result extent</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73624#M6655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I am selecting points, but I have an if statement that sets the map to center and zoom if there is only one feature returned.&amp;nbsp; I thought maybe my queryTask wasn't done executing, so I changed it to have a queryTask.on('complete') trying to make sure the executing is done before it finishes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The queryTask is also populating a dGrid, which looks just fine, so I know the queryTask is executing and returning what I would expect.&amp;nbsp; The problem looks to be limited to extent of the results.&amp;nbsp; The idea of a union isn't going to work with points.&amp;nbsp; I wonder if my problem is that the map is in a floating pane, and that there is some sort of delay.&amp;nbsp; Even after that pane is open, it still doesn't set the extent correctly.&amp;nbsp; From what I can see, it is almost always centered on the first point returned from the query.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've seen a few other threads with people having the same problem, I have to wonder if there is an issue with graphicsExtent itself.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://jsfiddle.net/schlot/9zv22/1/"&gt;http://jsfiddle.net/schlot/9zv22/1/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2014 13:43:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73624#M6655</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2014-03-17T13:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Zooming to query result extent</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73625#M6656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For future references... It's 2020 and I'm having the same issue you described using &lt;SPAN style="background-color: #ffffff;"&gt;graphicsUtils.graphicsExtent with a point layer. I develop using js api version 3.x. Turns out, that for some reason one feature in the array returned from the REST query is coming with the following geometry:&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;{&lt;BR /&gt;&amp;nbsp; "geometry": {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "x": "NaN",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "y": "NaN",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "spatialReference":&amp;nbsp; ...&lt;BR /&gt;&amp;nbsp; },&lt;BR /&gt;&amp;nbsp; "attributes": {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Our users add points to this layer using Arcmap 10.5 and Arcmap 10.7 and I couldn't find out why sometimes this null geometry happens.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you query the database to view this bad registry with sqldeveloper, you will find some null data inside shape column:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/498843_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At least, that was what happened here. I would recomend checking the array for NaN data before using&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;graphicsUtils.graphicsExtent to filter out bad data like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt; //note that NaN here is a string&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;var goodFeatures = features.filter(f =&amp;gt; f.geometry.x === "NaN" || &lt;SPAN&gt;f&lt;/SPAN&gt;&lt;SPAN&gt;.geometry.y === "NaN"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;var extent = graphicsUtils.graphicsExtent(goodFeatures)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;When I set the map with a bad extent, the map simply disapear and&amp;nbsp;breaks the app.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2020 16:53:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zooming-to-query-result-extent/m-p/73625#M6656</guid>
      <dc:creator>CarlosNantes</dc:creator>
      <dc:date>2020-07-03T16:53:02Z</dc:date>
    </item>
  </channel>
</rss>

