<?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: ZoomToLayer does not work as expected in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728648#M19418</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Kaspatoo&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;yes this were possible I think altough it is more complex.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I do not really understand why my ZoomToLayer works different from ArcMaps ZoomToLayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There must be a difference. I cannot imagine that ArcMap is working like you suggested.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I really would prefer to find the correct solution also for better understanding ArcGIS work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Mar 2012 08:57:35 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2012-03-28T08:57:35Z</dc:date>
    <item>
      <title>ZoomToLayer does not work as expected</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728644#M19414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Kaspatoo&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I implemented a ZoomToLayer method.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I did like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//00480000016r000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//00480000016r000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There its done this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activeView.Extent = layer.AreaOfInterest;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activeView.Refresh();&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;The layer is from the selectedItem in TOC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In my case I still have Layer throuh a search.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Imap.get_Layers()&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;using&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;layer.AreaOfInterest
ArcMap.Document.ActiveView&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Later my implementation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void zoomTo(IEnvelope extent, IActiveView activeView)
&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;&amp;nbsp; activeView.Extent = extent;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activeView.Refresh();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well theres is some kind of "zoom" but not the right one. Because it doesnt matter how many features are in this layer, the zoom is always done to the same scale.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;After I did my zoom and then clickling right in TOC on this layer and chose "ZoomToLayer" ArcMap zooms perfectly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess the problem is ILayer.AreaOfInterest. Because its describbed as "The default area of interest for the layer.". Well if the featureClass changes, this layer is pointing to and now there are less features and the overall area is much smaller than before in my mind the area of Interest shrinked. But I could imagine that ArcMap is not thinking this way and is still holding the maximum are it ever had for ever.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But then I wonder why the arcMap function ZoomToLayer is able to handle this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe an additional information. I am adding features to the specific fetatureclass but only the new added ones will be shown by the layer due to a definition query. thats why I am thinking of the max area ever because the features still exists in featureclass but not in the layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope someone can help me. Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;my zoom:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]13022[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcMaps zoom:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]13024[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:07:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728644#M19414</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T07:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: ZoomToLayer does not work as expected</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728645#M19415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you are zooming to an area based on features selected (or some other criteria that are marked before you begin the zoom) then what you do is to loop thru the features and build a new envelope with the union of all the selected feature shapes (IEnvelope.Union().)&amp;nbsp; When you have that envelope then you expand it (IEnvelope.Expand()) to ensure a surrounding buffer and then set the ActiveView.Extent and Refresh.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Mar 2012 13:20:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728645#M19415</guid>
      <dc:creator>GeorgeFaraj</dc:creator>
      <dc:date>2012-03-27T13:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: ZoomToLayer does not work as expected</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728646#M19416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Kaspatoo&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;yes, for single feature im still doing this and this works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But I want to implement exactly the logic of what ArcMaps "ZoomToLayer" does.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The layer is in the TOC which I am searching as described above and which uses a DefinitionQuery.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Mar 2012 14:09:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728646#M19416</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-03-27T14:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: ZoomToLayer does not work as expected</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728647#M19417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;One way to do this is to query the feature layer (use IFeatureLayer.Search so that it respects the definition query) and add the feature geometries to a geometry bag.&amp;nbsp; Then zoom to the envelope of the geometry bag.&amp;nbsp; You can also use IEnumGeometryBind together with ITopologicalOperator.ConstructUnion to union the features together, after which you would zoom to the envelope of the resulting polygon.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Mar 2012 14:33:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728647#M19417</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2012-03-27T14:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: ZoomToLayer does not work as expected</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728648#M19418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Kaspatoo&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;yes this were possible I think altough it is more complex.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I do not really understand why my ZoomToLayer works different from ArcMaps ZoomToLayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There must be a difference. I cannot imagine that ArcMap is working like you suggested.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I really would prefer to find the correct solution also for better understanding ArcGIS work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 08:57:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728648#M19418</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-03-28T08:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: ZoomToLayer does not work as expected</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728649#M19419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yours doesn't work the same because the AreaOfInterest property returns the spatially referenced extent of the layer, not the minimum bounding extent of the features within the layer.&amp;nbsp; If you want to do the exact same thing that ArcMap does then you can call the actual ArcMap command.&amp;nbsp; To do this you'll need to set the context item reference on the current contents view.&amp;nbsp; The code below is a VBA macro that shows how to do this.&amp;nbsp; It uses the selected layer in the TOC to set the context item but you can modify it to use any layer reference you want.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Sub ZoomToLayer()
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim mxDoc As IMxDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set mxDoc = ThisDocument
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim layer As IFeatureLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set layer = mxDoc.SelectedLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxDoc.CurrentContentsView.ContextItem = layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim uid As uid
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set uid = New uid
&amp;nbsp;&amp;nbsp;&amp;nbsp; uid.Value = "{18DF94D9-0F8A-11D2-94B1-080009EEBECB}:7"
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim commandItem As ICommandItem
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set commandItem = Application.Document.CommandBars.Find(uid)
&amp;nbsp;&amp;nbsp;&amp;nbsp; commandItem.Execute
End Sub
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:07:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728649#M19419</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2021-12-12T07:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: ZoomToLayer does not work as expected</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728650#M19420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Kaspatoo&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi thanks for this,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;a further solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But one question any more.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you not know what exactly this Button does internally or are you not allowed to tell internal functionality (of this button)?.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Well I just say because in my mind the best and clearest programming were to implement the right code directly and not reference other buttons (by which this implementation loses portability) or implementing some code which runs over several corners.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But thanks for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;edit:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;another question to the featureLayer.Search&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;when I use a queryFilter of null will I get all features in featureClass or only the shown ones in the layer (so is the query defininition still expected or have I to add it in the query filter?)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Mar 2012 07:30:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728650#M19420</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-03-29T07:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: ZoomToLayer does not work as expected</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728651#M19421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For whoever having similar problem, IGeodataSet.Extent (&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//0025000003m6000000" title="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//0025000003m6000000"&gt;http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//0025000003m6000000&lt;/A&gt; ) might be interesting&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To update the extent, we can use IFeatureClassManage.UpdateExtent (&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/IFeatureClassManage_Interface/0025000002s1000000/" title="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/IFeatureClassManage_Interface/0025000002s1000000/"&gt;http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/IFeatureClassManage_Interface/0025000002s1000000/&lt;/A&gt; )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Sep 2015 16:32:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/zoomtolayer-does-not-work-as-expected/m-p/728651#M19421</guid>
      <dc:creator>YuanLiu</dc:creator>
      <dc:date>2015-09-23T16:32:07Z</dc:date>
    </item>
  </channel>
</rss>

