AnsweredAssumed Answered

ZoomToLayer does not work as expected

Question asked by geonetadmin on Mar 27, 2012
Latest reply on Sep 23, 2015 by YLiu-esristaff
Original User: Kaspatoo


I implemented a ZoomToLayer method.
I did like this:

There its done this way:
      activeView.Extent = layer.AreaOfInterest;

The layer is from the selectedItem in TOC.
In my case I still have Layer throuh a search.


Later my implementation:
        public static void zoomTo(IEnvelope extent, IActiveView activeView)
            activeView.Extent = extent;

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.
After I did my zoom and then clickling right in TOC on this layer and chose "ZoomToLayer" ArcMap zooms perfectly.
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.
But then I wonder why the arcMap function ZoomToLayer is able to handle this.

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.

Hope someone can help me. Thanks.

my zoom:
ArcMaps zoom: