Converts a map coordinate to a screen location.
[Visual Basic 6.0] Sub FromMapPoints(
ByVal MapDescription As IMapDescription, _
ByVal mapDisplay As IImageDisplay, _
ByVal mapPoints As IPointCollection, _
screenXValues As ILongArray, _
screenYValues As ILongArray _
)
[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 );
[Java] public void fromMapPoints ( IMapDescription MapDescription, IImageDisplay mapDisplay, IPointCollection mapPoints, ILongArray screenXValues, ILongArray screenYValues ) throws IOException, AutomationException
[C++] HRESULT FromMapPoints( IMapDescription* MapDescription, IImageDisplay* mapDisplay, IPointCollection* mapPoints, ILongArray** screenXValues, ILongArray** screenYValues );
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
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 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());
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 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.
Dim pMapServer As IMapServer'Create image display
Dim pImageDisp As IImageDisplay
Set pImageDisp = New ImageDisplay
pImageDisp.Height = 400
pImageDisp.Width = 600
'Get map coordinates (upper left corner of map extent)
Dim pExtent As IEnvelope
Set pExtent = pMapDesc.MapArea.Extent
Dim pPoint As IPoint
Set pPoint = New Point
pPoint.x = pExtent.XMin
pPoint.y = pExtent.YMax
'Add point to point collection
Dim pPointCollection As IPointCollection
Set pPointCollection = New Multipoint
pPointCollection.AddPoint pPoint
'Convert map coordinates to screen location
Dim pScreenXValues As ILongArray, pScreenYValues As ILongArray
pMapServer.FromMapPoints pMapDesc, pImageDisp, pPointCollection, _
pScreenXValues, pScreenYValues
'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:
MsgBox pScreenXValues.Element(0)
MsgBox pScreenYValues.Element(0)