ArcObjects Library Reference  

GeographicCoordinates

About the Creating a toolbar of globe tools Sample

[C#]

GeographicCoordinates.cs

using ESRI.ArcGIS.GlobeCore;
using ESRI.ArcGIS.Analyst3D;

namespace GlobeGraphicsToolbar
{
    public class GeographicCoordinates
    {
        private double _longitude;
        private double _latitude;
        private double _altitudeInKilometers;

        public GeographicCoordinates(IGlobe globe, int screenX, int screenY)
        {
            GetGeographicCoordinates(globe, screenX, screenY, ref _longitude, ref _latitude, ref _altitudeInKilometers);
        }

        private void GetGeographicCoordinates(IGlobe globe, int screenX, int screenY, ref double longitude, ref double latitude, ref double altitudeInKilometers)
        {
            IGlobeDisplay globeDisplay = globe.GlobeDisplay;

            ISceneViewer sceneViewer = globeDisplay.ActiveViewer;

            ICamera camera = globeDisplay.ActiveViewer.Camera;

            IGlobeViewUtil globeViewUtil = camera as IGlobeViewUtil;

            globeViewUtil.WindowToGeographic(globeDisplay, sceneViewer, screenX, screenY, true, out longitude, out latitude, out altitudeInKilometers);
        }

        public double Longitude
        {
            get
            {
                return _longitude;
            }
        }

        public double Latitude
        {
            get
            {
                return _latitude;
            }
        }

        public double AltitudeInKilometers
        {
            get
            {
                return _altitudeInKilometers;
            }
        }    
    }
}
[Visual Basic .NET]

GeographicCoordinates.vb

Imports Microsoft.VisualBasic
Imports System
Imports ESRI.ArcGIS.GlobeCore
Imports ESRI.ArcGIS.Analyst3D

Namespace GlobeGraphicsToolbar
	Public Class GeographicCoordinates
		Private _longitude As Double
		Private _latitude As Double
		Private _altitudeInKilometers As Double

		Public Sub New(ByVal globe As IGlobe, ByVal screenX As Integer, ByVal screenY As Integer)
			GetGeographicCoordinates(globe, screenX, screenY, _longitude, _latitude, _altitudeInKilometers)
		End Sub

		Private Sub GetGeographicCoordinates(ByVal globe As IGlobe, ByVal screenX As Integer, ByVal screenY As Integer, ByRef longitude As Double, ByRef latitude As Double, ByRef altitudeInKilometers As Double)
			Dim globeDisplay As IGlobeDisplay = globe.GlobeDisplay

			Dim sceneViewer As ISceneViewer = globeDisplay.ActiveViewer

			Dim camera As ICamera = globeDisplay.ActiveViewer.Camera

			Dim globeViewUtil As IGlobeViewUtil = TryCast(camera, IGlobeViewUtil)

			globeViewUtil.WindowToGeographic(globeDisplay, sceneViewer, screenX, screenY, True, longitude, latitude, altitudeInKilometers)
		End Sub

		Public ReadOnly Property Longitude() As Double
			Get
				Return _longitude
			End Get
		End Property

		Public ReadOnly Property Latitude() As Double
			Get
				Return _latitude
			End Get
		End Property

		Public ReadOnly Property AltitudeInKilometers() As Double
			Get
				Return _altitudeInKilometers
			End Get
		End Property
	End Class
End Namespace