GeoCoordinate.Course 属性

定义

获取或设置行进方向(以相对于真北的度数为单位)。

public:
 property double Course { double get(); void set(double value); };
public double Course { get; set; }
member this.Course : double with get, set
Public Property Course As Double

属性值

行进方向(以相对于真北的度数为单位)。

例外

Course 的设定超出了有效范围。

示例

以下示例打印Course当前位置 的 GeoCoordinateSpeed 属性。

static void GetLocationCourseAndSpeed()
{
    GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();

    watcher.TryStart(true, TimeSpan.FromMilliseconds(1000));

    if (watcher.Position.Location.IsUnknown != true)
    {
        GeoCoordinate coord = watcher.Position.Location;

        Console.WriteLine("Course: {0}, Speed: {1}",
            coord.Course,
            coord.Speed);
    }
    else
    {
        Console.WriteLine("Unknown");
    }
}

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.Course,
            coord.Speed) 'NaN if not available.
    Else
        Console.WriteLine("Location unknown.")
    End If

End Sub

注解

有效范围包括 0.0 到 360.0 的值,如果未 Double.NaN 定义标题,则为 。

适用于