GeoCoordinate.Speed Property

.NET Framework (current version)

Gets or sets the speed in meters per second.

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

Public Property Speed As Double

Property Value

Type: System.Double

The speed in meters per second. The speed must be greater than or equal to zero, or NaN.

Exception Condition

Speed is set outside the valid range.

The following example prints the Course and Speed properties of the current location's GeoCoordinate.

Public Sub GetLocationCourseAndSpeed()
    Dim watcher As GeoCoordinateWatcher
    watcher = New System.Device.Location.GeoCoordinateWatcher()
    watcher.TryStart(False, TimeSpan.FromMilliseconds(1000))

    If Not watcher.Position.Location.IsUnknown Then
        Dim coord As GeoCoordinate = watcher.Position.Location
        Console.WriteLine("Course: {0}, Speed: {1}",
            coord.Speed) 'NaN if not available.
        Console.WriteLine("Location unknown.")
    End If

End Sub

.NET Framework
Available since 4.0
Windows Phone Silverlight
Available since 7.0
Return to top