<?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: Query Feature and Zoom in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545810#M50818</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Stevel &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; thanks, That's exactly what i needed&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Carl&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Jan 2012 18:31:08 GMT</pubDate>
    <dc:creator>CarlSunderman1</dc:creator>
    <dc:date>2012-01-11T18:31:08Z</dc:date>
    <item>
      <title>Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545804#M50812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've searched here and the rest forums and can't seem to find an answer. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a php page that when a value is click, a fancybox iframe opens with data, a floor plan, and a map of the building. i have passed the variable to javascript but am unable to see how to pass the variable to the map to zoom to the feature(QueryTask?). i've tried using query?where= but i seem to be way off. i've looked into the QueryTask, but have been unable to find an example of what i'm trying to accomplish. Does anyone have an example i can look at?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jan 2012 22:05:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545804#M50812</guid>
      <dc:creator>CarlSunderman1</dc:creator>
      <dc:date>2012-01-06T22:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545805#M50813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;i have passed the variable to javascript but am unable to see how to pass the variable to the map to zoom to the feature(QueryTask?)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Carl,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you provide further information - which variable are you passing to the map? Have you configured a query and querytask?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you provide a link to your site, or some sample code?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Jan 2012 23:06:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545805#M50813</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2012-01-08T23:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545806#M50814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Unfortunately, our server is on our intranet. I'm passing the objectid value to js Is a query task really needed? there is no other way to pass the value?&amp;nbsp; the query tasks i have seen seem to be more related to the data table and i can't seem to find a simple example of passing a variable to the query task to pan and zoom&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i did find this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;function zoomRow(id){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectionLayer.clear();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.some(map.graphics.graphics,function(graphic){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (graphic.attributes.ObjectID.toString() === id) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var selectedState = new esri.Graphic(graphic.geometry).setAttributes(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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; graphic.attributes);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectionLayer.add(selectedState);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var stateExtent = selectedState.geometry.getExtent().expand(5.0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(stateExtent);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here &lt;/SPAN&gt;&lt;A href="http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2009/12/14/Add-a-Zoom-button-to-a-DataGrid.aspx"&gt;http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2009/12/14/Add-a-Zoom-button-to-a-DataGrid.aspx&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;which basically does what i want, i just need to do an onload, i think&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2012 17:26:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545806#M50814</guid>
      <dc:creator>CarlSunderman1</dc:creator>
      <dc:date>2012-01-09T17:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545807#M50815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;i can't seem to find a simple example of passing a variable to the query task to pan and zoom&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The sample you referenced may not be perfectly suited to your task - it's passing in the OBJECTID of the feature, then iterating through each graphic on the map to see whether its ID matches. It then zooms to the matching graphic.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another approach is to run a query, then zoom to the extent of the feature(s) which are returned. Assuming that you know the OBJECTID (or some other unique attribute) of your feature, you could use something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
//Define a new Query and QueryTask
queryTask = new esri.tasks.QueryTask(UrlToYourLayer);
query = new esri.tasks.Query();
query.returnGeometry = true;
query.outFields = ["field1","field2"];


//The query's where clause will be attribute query to find the feature
query.where = "'OBJECTID = 123'";


//Run the query. Its results are returned in the function showResults
queryTask.execute(query,showResults);


//results is an array of any found features. Assuming you only want the first feature:
function showResults(results) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var result = results[0];
&amp;nbsp;&amp;nbsp;&amp;nbsp; var extent = result.geometry.getExtent().expand(5.0);
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(extent);
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(Note that I haven't actually tested this so it's more of a conceptual overview.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:37:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545807#M50815</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2021-12-11T23:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545808#M50816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks stevel&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With outfields populated i get a &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"dojo.io.script.jsonp_dojoIoScript1._jsonpCallback({"error":{"code":400,"message":"Unable to complete&amp;nbsp; operation.","details":["Unable to complete Query operation."]}});" error&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;with outfields empty i get&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"TypeError: Cannot read property 'geometry' of undefined {}"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;regardless, the map errors and doesn't draw&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;BR /&gt;&amp;nbsp; dojo.require("esri.map");&lt;BR /&gt;&amp;nbsp; dojo.require("esri.tasks.query");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; function init() {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; map = new esri.Map("mapDiv");&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var basemapURL= "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://" rel="nofollow" target="_blank"&gt;http://&lt;/A&gt;&lt;SPAN&gt;&amp;lt;myserver&amp;gt;/ArcGIS/rest/services/&amp;lt;myservice&amp;gt;/MapServer"&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var basemap = new esri.layers.ArcGISDynamicMapServiceLayer(basemapURL);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayer(basemap);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // sample Query Task&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // define variables&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var queryTask, query; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Define a new Query and QueryTask&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; queryTask = new esri.tasks.QueryTask("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://" rel="nofollow" target="_blank"&gt;http://&lt;/A&gt;&lt;SPAN&gt;&amp;lt;myserver&amp;gt;/ArcGIS/rest/services/&amp;lt;myservice&amp;gt;/MapServer/7");&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; query = new esri.tasks.Query();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.returnGeometry = true;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.outFields = ["BUILDNG_NO","ADDRESS_ID"];&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//The query's where clause will be attribute query to find the feature&lt;BR /&gt; query.where = "OBJECTID=6742";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//Run the query. Its results are returned in the function showResults&lt;BR /&gt; queryTask.execute(query,showResults);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//results is an array of any found features. Assuming you only want the first feature:&lt;BR /&gt;&amp;nbsp;&amp;nbsp; function showResults(results) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var result = results[0];&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var extent = result.geometry.getExtent().expand(5.0);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(extent);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // end of Query Task&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; dojo.addOnLoad(init);&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2012 00:08:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545808#M50816</guid>
      <dc:creator>CarlSunderman1</dc:creator>
      <dc:date>2012-01-10T00:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545809#M50817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You know how I said I hadn't actually tested that code? There were a couple of typos in there. The showResults section should look something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function showResults(results) {
&amp;nbsp; var result = results.features[0];
&amp;nbsp; var extent = result.geometry.getExtent().expand(5.0);
&amp;nbsp; map.setExtent(esri.geometry.geographicToWebMercator(extent));
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The key missing thing was results&lt;/SPAN&gt;&lt;STRONG&gt;.features&lt;/STRONG&gt;&lt;SPAN&gt;[0], to obtain the first feature in the results.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may also need to translate the extent from geographic coordinates to web mercator, depending on your datasets (as in the attached demo, which zooms to the extent of a polygon on opening. That's because the query uses a dataset specified in decimal degrees, while the basemap is in Web Mercator.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:37:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545809#M50817</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2021-12-11T23:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545810#M50818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Stevel &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; thanks, That's exactly what i needed&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Carl&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 18:31:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545810#M50818</guid>
      <dc:creator>CarlSunderman1</dc:creator>
      <dc:date>2012-01-11T18:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545811#M50819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Cool, glad you got it sorted.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The first sample was pretty dodgy - it loaded the map then immediately ran the query, which isn't very useful.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In case anyone reads this thread later, attached is a more useable version. It waits for the user to enter a query string, then runs the query when the user hits the Query button.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you step through it in &lt;/SPAN&gt;&lt;A href="http://getfirebug.com/"&gt;FireBug &lt;/A&gt;&lt;SPAN&gt;you can see what's happening.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 21:27:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545811#M50819</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2012-01-11T21:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545812#M50820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Steve,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks so much for the query sample code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a mapping application that I need to zoom to ALL the features returned, not just the 1st feature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to modify your sample but was not getting anywhere.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Mar 2012 17:58:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545812#M50820</guid>
      <dc:creator>ChristopherPollard</dc:creator>
      <dc:date>2012-03-29T17:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545813#M50821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I need to zoom to ALL the features returned, not just the 1st feature. I tried to modify your sample but was not getting anywhere.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See the section:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function showResults(results) {
&amp;nbsp; //This function is run when the query has finished.
&amp;nbsp; //It zooms the map to the extent of the first feature returned by the query.
&amp;nbsp; var result = results.features[0];
&amp;nbsp; var extent = result.geometry.getExtent().expand(5.0); 
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You'll want to iterate through each feature and &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/extent.htm#union" rel="nofollow noopener noreferrer" target="_blank"&gt;union&lt;/A&gt;&lt;SPAN&gt; the extent so that it expands to include all features. Pseudo-code is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var fullExtent;
for each result in results:
&amp;nbsp; thisExtent = result.geometry.getExtent();
&amp;nbsp; fullExtent.union(fullExtent);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I haven't tested this, so you might need to initialise fullExtent as the extent of the first feature, before union-ing it with all of the other features' extents.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:37:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545813#M50821</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2021-12-11T23:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545814#M50822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The simplest (and fastest) way to get the extent of an array of graphics is to use &lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: monospace;"&gt;esri&lt;/SPAN&gt;&lt;SPAN style="color: #666600; font-family: monospace;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: monospace;"&gt;graphicsExtent&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;&lt;SPAN style="color: #000088; font-family: monospace;"&gt;var&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: monospace;"&gt; Extent &lt;/SPAN&gt;&lt;SPAN style="color: #666600; font-family: monospace;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: monospace;"&gt; esri&lt;/SPAN&gt;&lt;SPAN style="color: #666600; font-family: monospace;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: monospace;"&gt;graphicsExtent&lt;/SPAN&gt;&lt;SPAN style="color: #666600; font-family: monospace;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: monospace;"&gt;FeatureSet&lt;/SPAN&gt;&lt;SPAN style="color: #666600; font-family: monospace;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-family: monospace;"&gt;features&lt;/SPAN&gt;&lt;SPAN style="color: #666600; font-family: monospace;"&gt;);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is a little gem helper function found in the esri namespace:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/namespace_esri.htm#esri.graphicsExtent"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/namespace_esri.htm#esri.graphicsExtent&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 07:25:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545814#M50822</guid>
      <dc:creator>DavidSpriggs</dc:creator>
      <dc:date>2012-03-30T07:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545815#M50823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I also have a need to iterate and union the geometry of each feature in my code.&amp;nbsp; I can iterate through each feature but I am having trouble union-ing the extents.&amp;nbsp; I basically get the extent of the last feature stored in fullExtent.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 var fullExtent;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var i = 0, il = results.features.length; i &amp;lt; il; i++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fullExtent = results.features&lt;I&gt;.geometry.getExtent();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fullExtent.union(fullExtent);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I have a need to select these features and display a graphic on the map.&amp;nbsp; I have a findtask setup but it is only useful for one feature at a time, at least this is what all the sample show.&amp;nbsp; i have not figured out how to make it work for multiple features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Todd&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:37:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545815#M50823</guid>
      <dc:creator>ToddMcNeil1</dc:creator>
      <dc:date>2021-12-11T23:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Query Feature and Zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545816#M50824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;THANKS THAT HELPED ME !!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2012 01:34:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-feature-and-zoom/m-p/545816#M50824</guid>
      <dc:creator>lbowne</dc:creator>
      <dc:date>2012-08-21T01:34:01Z</dc:date>
    </item>
  </channel>
</rss>

