<?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: Zoom to extent of query results. in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/zoom-to-extent-of-query-results/m-p/200452#M4713</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Rene,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That worked great! Thanks for the quick and helpful response.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Mar 2011 11:58:44 GMT</pubDate>
    <dc:creator>ThomasDyer</dc:creator>
    <dc:date>2011-03-04T11:58:44Z</dc:date>
    <item>
      <title>Zoom to extent of query results.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/zoom-to-extent-of-query-results/m-p/200450#M4711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm using the Flexviewer 2.2 Query widget. I would like the map to zoom to the extent of the query results. I used the following code plugged into the "onResults" function of the widget:&lt;/SPAN&gt;&lt;BR /&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; var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if (graphicsExtent)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; map.extent = graphicsExtent.expand(2.0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&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; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works fine ONCE, but will not work for the same query again. After stepping around the code, it seems that query results are stored somewhere and the query is not rerun every time, so my little piece of code is not run again. I have tried moving the code around, clearing arrays, clearing graphics layers and still nothing. So, I come humbly before the masters seeking advice. Be gentle I'm new to programming, especially Flex.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 19:48:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/zoom-to-extent-of-query-results/m-p/200450#M4711</guid>
      <dc:creator>ThomasDyer</dc:creator>
      <dc:date>2011-03-03T19:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to extent of query results.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/zoom-to-extent-of-query-results/m-p/200451#M4712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looking at the Query Widget, it looks like the query is just run the one time on the first load and results parsed and stored in queryResultAC. This is probably to save the time of having to rerun the query each time you close/open the widget.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you'd like to zoom the query results each time the widget is open, you can listen for the addedToStage event on something. I tried it out and added it to the QueryResultDataGroup&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;Query:QueryResultDataGroup id="queryResultDG" addedToStage="queryResultDG_addedToStageHandler(event)" ...&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then do something like this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
protected function queryResultDG_addedToStageHandler(event:Event):void
{
 if (graphicsLayer) // need this because on first load, value is null
&amp;nbsp; map.extent = GraphicUtil.getGraphicsExtent(ArrayCollection(graphicsLayer.graphicProvider).toArray());
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That should get you started.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:59:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/zoom-to-extent-of-query-results/m-p/200451#M4712</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-11T09:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to extent of query results.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/zoom-to-extent-of-query-results/m-p/200452#M4713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Rene,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That worked great! Thanks for the quick and helpful response.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2011 11:58:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/zoom-to-extent-of-query-results/m-p/200452#M4713</guid>
      <dc:creator>ThomasDyer</dc:creator>
      <dc:date>2011-03-04T11:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to extent of query results.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/zoom-to-extent-of-query-results/m-p/200453#M4714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Looking at the Query Widget, it looks like the query is just run the one time on the first load and results parsed and stored in queryResultAC. This is probably to save the time of having to rerun the query each time you close/open the widget.&lt;BR /&gt;&lt;BR /&gt;If you'd like to zoom the query results each time the widget is open, you can listen for the addedToStage event on something. I tried it out and added it to the QueryResultDataGroup&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;Query:QueryResultDataGroup id="queryResultDG" addedToStage="queryResultDG_addedToStageHandler(event)" ...&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Then do something like this.&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
protected function queryResultDG_addedToStageHandler(event:Event):void
{
 if (graphicsLayer) // need this because on first load, value is null
&amp;nbsp; map.extent = GraphicUtil.getGraphicsExtent(ArrayCollection(graphicsLayer.graphicProvider).toArray());
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;That should get you started.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How do you do this with ArcGIS Silverlight API?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:59:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/zoom-to-extent-of-query-results/m-p/200453#M4714</guid>
      <dc:creator>AsseticTop_Administrator</dc:creator>
      <dc:date>2021-12-11T09:59:17Z</dc:date>
    </item>
  </channel>
</rss>

