Converts a screen location to a map coordinate.
[Visual Basic 6.0] Function ToMapPoints(
ByVal MapDescription As IMapDescription, _
ByVal mapDisplay As IImageDisplay, _
ByVal screenXValues As ILongArray, _
ByVal screenYValues As ILongArray _
) As IPointCollection
[Visual Basic .NET] Public Function ToMapPoints ( _ ByVal MapDescription As IMapDescription, _ ByVal mapDisplay As IImageDisplay, _ ByVal screenXValues As ILongArray, _ ByVal screenYValues As ILongArray _ ) As IPointCollection
[C#] public IPointCollection ToMapPoints ( IMapDescription MapDescription, IImageDisplay mapDisplay, ILongArray screenXValues, ILongArray screenYValues );
[Java] public IPointCollection toMapPoints ( IMapDescription MapDescription, IImageDisplay mapDisplay, ILongArray screenXValues, ILongArray screenYValues ) throws IOException, AutomationException
[C++] HRESULT ToMapPoints( IMapDescription* MapDescription, IImageDisplay* mapDisplay, ILongArray* screenXValues, ILongArray* screenYValues, IPointCollection** mapPoints );
Parameters
MapDescription [in]
MapDescription is a parameter of type IMapDescription
mapDisplay [in]
mapDisplay is a parameter of type IImageDisplay
screenXValues [in]
screenXValues is a parameter of type ILongArray
screenYValues [in]
screenYValues is a parameter of type ILongArray
mapPoints [out, retval]
mapPoints is a parameter of type IPointCollection
The following sample code shows how to convert the lower left corner of your map image (screen location) to map coordinates. 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
Dim pMapDesc As IMapDescription
'Create image display
Dim pImageDisp As IImageDisplay
Set pImageDisp = New ImageDisplay
pImageDisp.Height = 400
pImageDisp.Width = 500
'Get screen location (lower left corner of image)
Dim pScreenXValues As ILongArray, pScreenYValues As ILongArray
Set pScreenXValues = New LongArray
Set pScreenYValues = New LongArray
pScreenXValues.Add 0
'Be aware that origin of screen coordinate system is upper left corner!
pScreenYValues.Add 400
'Convert screen location to map coordinates
Dim pPointCollection As IPointCollection
Set pPointCollection = pMapServer.ToMapPoints(pMapDesc, pImageDisp, _
pScreenXValues, pScreenYValues)
Dim pPoint As IPoint
Set pPoint = pPointCollection.Point(0)
MsgBox pPoint.X
MsgBox pPoint.Y