This document is archived and information here might be outdated.  Recommended version.


Get Geographic Coordinates in Globe Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Get Geographic Coordinates in Globe Snippet

Convert screen coordinates (pixels) to real world map units in geographic (latitude and longitude).

[C#]
///<summary>Convert screen coordinates (pixels) to real world map units in geographic (latitude and longitude).</summary>
///  
///<param name="xView">A System.Int32 that is the X screen coordinate. Example: 100</param>
///<param name="yView">A System.Int32 that is the Y screen coordinate. Example: 200</param>
///<param name="globeDisplay">An IGlobeDisplay interface.</param>
///   
///<remarks>Point.X is the longitude, Point.Y is the latitude and Point.Z is the altitude</remarks>
public ESRI.ArcGIS.Geometry.IPoint GetGeographicCoordinatesInGlobe(System.Int32 xView, System.Int32 yView, ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay)
{
  //Get the geographic coordinates from the window coordinates
  ESRI.ArcGIS.Geometry.IPoint point;
  System.Object ppOwner;
  System.Object ppObject;
  globeDisplay.Locate(globeDisplay.ActiveViewer, xView, yView, false, true, out point, out ppOwner, out ppObject);
  return point;
}
[Visual Basic .NET]
'''<summary>Convert screen coordinates (pixels) to real world map units in geographic (latitude and longitude).</summary>
'''  
'''<param name="xView">A System.Int32 that is the X screen coordinate. Example: 100</param>
'''<param name="yView">A System.Int32 that is the Y screen coordinate. Example: 200</param>
'''<param name="globeDisplay">An IGlobeDisplay interface.</param>
'''   
'''<remarks>Point.X is the longitude, Point.Y is the latitude and Point.Z is the altitude</remarks>
Public Function GetGeographicCoordinatesInGlobe(ByVal xView As System.Int32, ByVal yView As System.Int32, ByVal globeDisplay As ESRI.ArcGIS.GlobeCore.IGlobeDisplay) As ESRI.ArcGIS.Geometry.IPoint

  ' Get the geographic coordinates from the window coordinates
  Dim point As ESRI.ArcGIS.Geometry.IPoint=Nothing
  Dim ppOwner As System.Object=Nothing
  Dim ppObject As System.Object=Nothing
  globeDisplay.Locate(globeDisplay.ActiveViewer, xView, yView, False, True, point, ppOwner, ppObject)

  Return point

End Function

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.3DAnalyst
  • ESRI.ArcGIS.Geometry
  • ESRI.ArcGIS.GlobeCore
  • ESRI.ArcGIS.System