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

ICenterAndSize Interface

Provides access to the Center And Size Map Area Interface.

Product Availability

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

When To Use

Use ICenterAndSize to apply a new geographic extent to a map by specifying a center point and the height and width of the map image.

Members

Name Description
Read/write property Center The center of the map.
Read/write property Height The height of the map expressed in map units.
Read/write property Units The current map units.
Read/write property Width The width of the map expressed in map units.

CoClasses that implement ICenterAndSize

CoClasses and Classes Description
CenterAndSize The Center And Size coclass allows you to change the spatial extent of a map by specifying the center, size and units.

Remarks

One way to change the map extent is using the object CenterAndSize. Create a new CenterAndSize object and set the geographic extent by setting a center point, the height and the width of the map image. The height and width will be in map units. If the spatial reference of the map has changed, remember to adjust the center point coordinates and height and width units accordingly.

If the aspect ratio of the input map is different from the aspect ratio of the requested image, the returned map extent will be adjusted to fit the requested image.

[C#]

The following sample code shows how to change the geographic height and width of the map image using ICenterAndSize. It assumes that you already have a valid MapServerInfo 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.

IMapDescription mapDesc;
IMapServerInfo mapServerInfo;

IEnvelope extent=mapDesc.MapArea.Extent;
double lXMin, lXMax, lYMin, lYMax;

lXMin=extent.XMin;
lXMax=extent.XMax;
lYMin=extent.YMin;
lYMax=extent.YMax;

// Calculate center point of current map extent
IPoint centerPoint=new PointClass();
centerPoint.SpatialReference=mapDesc.SpatialReference;
centerPoint.X=lXMin + (lXMax - lXMin) / 2;
centerPoint.Y=lYMin + (lYMax - lYMin) / 2;

// Assign center point, map units and geographic height and width to
// new CenterAndSize object
ICenterAndSize centerSize=new CenterAndSizeClass();
centerSize.Center=centerPoint;
centerSize.Units=mapServerInfo.MapUnits;
centerSize.Height=12;
centerSize.Width=15;

// Assign new CenterAndScale object to MapDescription
mapDesc.MapArea=(IMapArea)centerSize;