Interface ICenterAndSize
Provides access to the Center And Size Map Area Interface.
[Guid("003C322D-E8C1-43E2-8DA3-3BCD81FDD2F8")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ICenterAndSize
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 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;
Properties
Center
The center of the map.
IPoint Center { get; set; }
Property Value
Height
The height of the map expressed in map units.
double Height { get; set; }
Property Value
Units
The current map units.
esriUnits Units { get; set; }
Property Value
Width
The width of the map expressed in map units.
double Width { get; set; }