ArcObjects Library Reference  (Carto)    

IMapServerLayout.ToPagePoints Method

Converts a screen location to a page coordinate.

[Visual Basic 6.0]
Function ToPagePoints(
    ByVal pageExtent As IEnvelope, _
    ByVal pageDisplay As IImageDisplay, _
    ByVal screenXValues As ILongArray, _
    ByVal screenYValues As ILongArray _
) As IPointCollection
[Visual Basic .NET]
Public Function ToPagePoints ( _
    ByVal pageExtent As IEnvelope, _
    ByVal pageDisplay As IImageDisplay, _
    ByVal screenXValues As ILongArray, _
    ByVal screenYValues As ILongArray _
) As IPointCollection
[C#]
public IPointCollection ToPagePoints (
    IEnvelope pageExtent,
    IImageDisplay pageDisplay,
    ILongArray screenXValues,
    ILongArray screenYValues
);
[Java]
public IPointCollection toPagePoints (
    IEnvelope pageExtent,
    IImageDisplay pageDisplay,
    ILongArray screenXValues,
    ILongArray screenYValues
)
throws
    IOException,
    AutomationException
[C++]
HRESULT ToPagePoints(
  IEnvelope* pageExtent,
  IImageDisplay* pageDisplay,
  ILongArray* screenXValues,
  ILongArray* screenYValues,
  IPointCollection** pagePoints
);
[C++]

Parameters

pageExtent [in]

  pageExtent is a parameter of type IEnvelope

pageDisplay [in]

  pageDisplay is a parameter of type IImageDisplay

screenXValues [in]

  screenXValues is a parameter of type ILongArray

screenYValues [in]

  screenYValues is a parameter of type ILongArray

pagePoints [out, retval]

  pagePoints is a parameter of type IPointCollection

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

Use ToPagePoints to convert pixel coordinates on the screen to page units coordinates on the layout.

[C#]

The following sample code shows how to convert the lower left corner of your layout image (screen location) to page coordinates. It assumes that you already have a valid MapServerLayout and PageDescription 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.

IMapServerLayout mapServerLayout;
IPageDescription pageDesc;
// Create image display
IImageDisplay imageDisp = new ImageDisplayClass();
imageDisp.Height = 550;
imageDisp.Width = 425;
// Get page extent
IEnvelope pageExtent = pageDesc.Extent ;
// Get screen location (lower left corner of image)
ILongArray screenXValues = new LongArrayClass();
ILongArray screenYValues = new LongArrayClass();
screenXValues.Add(0);
// Be aware that origin of screen coordinate system is upper left corner!
screenYValues.Add(550);
// Convert screen location to page coordinates
IPointCollection pointCollection;
pointCollection = mapServerLayout.ToPagePoints(pageExtent, imageDisp, screenXValues, screenYValues);
IPoint point = pointCollection.get_Point(0);
// Please note:
// 1. Origin of screen coordinate system is upper left corner
// 2. If aspect ratio of requested layout image is different from aspect ratio of
// input map layout, requested layout image will be adjusted to fit
// input map layout -> following screen locations are not necessarily 0:
MessageBox.Show(point.X.ToString());
MessageBox.Show(point.Y.ToString());

[Visual Basic 6.0]

The following sample code shows how to convert the lower left corner of your layout image (screen location) to page coordinates. It assumes that you already have a valid MapServerLayout and PageDescription 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 pMapServerLayout As IMapServerLayout
Dim pPageDesc As IPageDescription

'Create image display
Dim pPageDisp As IImageDisplay
Set pPageDisp = New ImageDisplay
pPageDisp.Height = 550
pPageDisp.Width = 425

'Get page extent
Dim pPageExtent As IEnvelope
Set pPageExtent = pPageDesc.Extent
   
'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 550

'Convert screen location to page coordinates
Dim pPointCollection As IPointCollection
Set pPointCollection = pMapServerLayout.ToPagePoints(pPageExtent, pPageDisp, _
                       pScreenXValues, pScreenYValues)
Dim pPoint As IPoint
Set pPoint = pPointCollection.Point(0)
'Please note: If aspect ratio of requested layout image is different from
'aspect ratio of input map layout, requested layout image will be adjusted to fit
'input map layout-> following page coordinates are not necessarily 0:
MsgBox pPoint.X
MsgBox pPoint.Y

See Also

IMapServerLayout Interface

 


Feedback Send feedback on this page