This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ESRI.ArcGIS.Snippets > Snippets > Get Geographic Coordinates in Globe Snippet (ArcObjects .NET 10.4 SDK) |
Convert screen coordinates (pixels) to real world map units in geographic (latitude and longitude).
///<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; }
'''<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