Converts a map coordinate to a screen location.
[Visual Basic .NET] Public Sub FromMapPoints ( _ ByVal MapDescription As IMapDescription, _ ByVal mapDisplay As IImageDisplay, _ ByVal mapPoints As IPointCollection, _ ByRef screenXValues As ILongArray, _ ByRef screenYValues As ILongArray _ )
[C#] public void FromMapPoints ( IMapDescription MapDescription, IImageDisplay mapDisplay, IPointCollection mapPoints, ref ILongArray screenXValues, ref ILongArray screenYValues );
[C++]
HRESULT FromMapPoints(
IMapDescription* MapDescription,
IImageDisplay* mapDisplay,
IPointCollection* mapPoints,
ILongArray** screenXValues,
ILongArray** screenYValues
);
[C++]Parameters
MapDescription [in]MapDescription is a parameter of type IMapDescription
mapDisplay [in]mapDisplay is a parameter of type IImageDisplay
mapPoints [in]mapPoints is a parameter of type IPointCollection
screenXValues [in, out]screenXValues is a parameter of type ILongArray
screenYValues [in, out]screenYValues is a parameter of type ILongArray
Product Availability
The following sample code shows how to convert the upper left corner of your map extent (map coordinates) to a screen location. 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;
// Create image display.
IImageDisplay imageDisp = new ImageDisplayClass();
imageDisp.Height = 400;
imageDisp.Width = 600;
// Get map coordinates (upper left corner of map extent).
IEnvelope extent = m_MapDesc.MapArea.Extent;
IPoint point = new PointClass();
point.X = extent.XMin;
point.Y = extent.YMax;
// Add point to point collection.
IPointCollection pointCollection = new MultipointClass();
System.Object pMissing = System.Reflection.Missing.Value;
pointCollection.AddPoint(point, ref pMissing, ref pMissing );
// Convert map coordinates to screen location.
ILongArray screenXValues = new LongArrayClass ();
ILongArray screenYValues = new LongArrayClass ();
mapServer.FromMapPoints(mapDesc, imageDisp, pointCollection, ref screenXValues, ref screenYValues);
// Please note:
// 1. Origin of screen coordinate system is upper left corner.
// 2. If aspect ratio of requested image is different from aspect
// ratio of input map, map extent will be adjusted to fit
// requested image -> following screen coordinates are not necessarily 0:
MessageBox.Show(screenXValues.get_Element(0).ToString());
MessageBox.Show(screenYValues.get_Element(0).ToString());