Interface IFeatureExtent
Provides access to the Feature Extent Map Area Interface.
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("FA56C255-CE10-46D9-AB63-505753DF12A4")]
public interface IFeatureExtent
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.
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;
Properties
DefaultScale
Scale at which the extent of a single point is drawn.
double DefaultScale { get; set; }
Property Value
Remarks
Use DefaultScale to control the map scale when zooming to a single point feature. The DefaultScale value only affects conditions where a single point feature is selected. This value will be ignored when selecting multiple points or when selecting other feature types. If this value is not set and FeatureIDs is comprised of a single point feature, the new spatial extent may be too large.
ExpandRatio
Ratio used to expand the extent.
double ExpandRatio { get; set; }
Property Value
Remarks
Use ExpandRatio to add a "buffer" around the requested geographic extent. For example, an ExpandRatio value of 1.5 will expand the map extent by 1.5 times.ExpandRatio should be used to ensure that the set of features can be viewed easily. Otherwise, some features may be at the very edge of the displayed map extent. If the ExpandRatio is not set (the default value is 1) some of the selected features will be located at the very edge of the map image. A number greater than 1 will "zoom out", providing a spatial buffer around the selected features. A number less than 1 will "zoom in".
FeatureIDs
The set of feature IDs.
IFIDSet FeatureIDs { get; set; }
Property Value
LayerID
The ID of the layer.
int LayerID { get; set; }
Property Value
MapName
Name of the map (data frame).
string MapName { get; set; }