語言

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當前位置 Speed的 和 GeoCoordinate 屬性。

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

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

    if (!watcher.Position.Location.IsUnknown)
    {
        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 標題未定義。

適用於