This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > IF > IFeatureExtent Interface (ArcObjects .NET 10.5 SDK) |
Provides access to the Feature Extent Map Area Interface.
Use IFeatureExtent to zoom to selected features of a layer.
Description | ||
---|---|---|
DefaultScale | Scale at which the extent of a single point is drawn. | |
ExpandRatio | Ratio used to expand the extent. | |
FeatureIDs | The set of feature IDs. | |
LayerID | The ID of the layer. | |
MapName | Name of the map (data frame). |
CoClasses and Classes | Description |
---|---|
FeatureExtent | The Feature Extent coclass allows you to zoom to selected features in a layer. |
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.
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;