Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

GeoCoordinate.Latitude Property

.NET Framework (current version)
 

Gets or sets the latitude of the GeoCoordinate.

Namespace:   System.Device.Location
Assembly:  System.Device (in System.Device.dll)

Public Property Latitude As Double

Property Value

Type: System.Double

Latitude of the location.

Exception Condition
ArgumentOutOfRangeException

Latitude is set outside the valid range.

Latitude can range from -90.0 to 90.0. Latitude is measured in degrees north or south from the equator. Positive values are north of the equator and negative values are south of the equator.

The following example prints the latitude and longitude values that are obtained from a GeoCoordinate.

Imports System.Device.Location
Module GetLocationEvent
    Public Class CLocation
        Private WithEvents watcher As GeoCoordinateWatcher
        Public Sub GetLocationDataEvent()
            watcher = New System.Device.Location.GeoCoordinateWatcher()
            AddHandler watcher.PositionChanged, AddressOf watcher_PositionChanged
            watcher.Start()

        End Sub

        Private Sub watcher_PositionChanged(ByVal sender As Object, ByVal e As GeoPositionChangedEventArgs(Of GeoCoordinate))
            PrintPosition(e.Position.Location.Latitude, e.Position.Location.Longitude)
            ' Uncomment the following to stop receiving updates after the first one.
            ' watcher.Stop()
        End Sub

        Private Sub PrintPosition(ByVal Latitude As Double, ByVal Longitude As Double)
            Console.WriteLine("Latitude: {0}, Longitude {1}", Latitude, Longitude)
        End Sub
    End Class


    Public Sub Main()
        Dim myLocation As New CLocation()
        myLocation.GetLocationDataEvent()
        Console.WriteLine("Enter any key to quit.")
        Console.ReadLine()
    End Sub

End Module

.NET Framework
Available since 4.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show:
© 2017 Microsoft