Provides access to the Center And Size Map Area Interface.
Product Availability
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
Description | ||
---|---|---|
Center | The center of the map. | |
Height | The height of the map expressed in map units. | |
Units | The current map units. | |
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.
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 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;