IFeatureExtent Interface (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > IF > IFeatureExtent Interface (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (Carto)  

IFeatureExtent Interface

Provides access to the Feature Extent Map Area Interface.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

When To Use

 Use IFeatureExtent to zoom to selected features of a layer.

Members

Name Description
Read/write property DefaultScale Scale at which the extent of a single point is drawn.
Read/write property ExpandRatio Ratio used to expand the extent.
Read/write property FeatureIDs The set of feature IDs.
Read/write property LayerID The ID of the layer.
Read/write property MapName Name of the map (data frame).

CoClasses that implement IFeatureExtent

CoClasses and Classes Description
FeatureExtent The Feature Extent coclass allows you to zoom to selected features in a layer.

Remarks

To use a FeatureExtent, the properties MapName, LayerID and FeatureIDs need to be set. You are likely to get unexpected results if these properties are not set. The ExpandRatio and DefaultScale properties are optional. If the ExpandRatio is not set some of the selected features will be located at the very edge of the map image. The DefaultScale value only affects conditions where a single point feature is selected. This will be the map scale in which the map will zoom to when a single point is selected.

[C#]

The following sample code shows how to zoom to selected features of a layer using IFeatureExtent. It assumes that you already have a valid MapServer and MapDescription object, and that you are not working with a server context. However, if you are developing an ArcGIS for Server application using a server context, you should not use New to create local ArcObjects, but you should always create objects within the server by calling CreateObject on IServerContext.

IMapServer mapServer;
IMapDescription mapDesc;

int layerID=0;
string strMapName=mapDesc.Name;

// Select a feature.
IQueryFilter filter=new QueryFilterClass();
filter.WhereClause="Name='Halifax' or Name='Alma'";
IFIDSet FIDSet=mapServer.QueryFeatureIDs(strMapName, layerID, filter);

// Zoom to selected features.
IFeatureExtent featExt=new FeatureExtentClass();
// Following line of code is not needed because you zoom to more than 1 point:
// featExt.DefaultScale=300000;
featExt.ExpandRatio=1.2;
featExt.FeatureIDs=FIDSet;
featExt.LayerID=layerID;
featExt.MapName=strMapName;

// Assign new FeatureExtent to MapDescription.
mapDesc.MapArea=(IMapArea)featExt;