共用方式為


GeoCoordinateWatcher.Position 屬性

定義

取得表示目前位置的 GeoCoordinate

public:
 property System::Device::Location::GeoPosition<System::Device::Location::GeoCoordinate ^> ^ Position { System::Device::Location::GeoPosition<System::Device::Location::GeoCoordinate ^> ^ get(); };
public System.Device.Location.GeoPosition<System.Device.Location.GeoCoordinate> Position { get; }
member this.Position : System.Device.Location.GeoPosition<System.Device.Location.GeoCoordinate>
Public ReadOnly Property Position As GeoPosition(Of GeoCoordinate)

屬性值

表示目前位置的 GeoCoordinate

實作

範例

在下列範例中 Location ,屬性的 Position 屬性會儲存在物件中 GeoCoordinate 。 如果已知,則會列印 的 GeoCoordinate 緯度和經度欄位。

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

    // Do not suppress prompt, and wait 1000 milliseconds to start.
    watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));

    GeoCoordinate coord = watcher.Position.Location;

    if (coord.IsUnknown != true)
    {
        Console.WriteLine("Lat: {0}, Long: {1}",
            coord.Latitude,
            coord.Longitude);
    }
    else
    {
        Console.WriteLine("Unknown latitude and longitude.");
    }
}
Public Sub GetLocationProperty()
    Dim watcher As New System.Device.Location.GeoCoordinateWatcher()
    watcher.TryStart(False, TimeSpan.FromMilliseconds(1000))

    Dim coord As GeoCoordinate = watcher.Position.Location

    If coord.IsUnknown <> True Then
        Console.WriteLine("Lat: {0}, Long: {1}", coord.Latitude, coord.Longitude)
    Else
        Console.WriteLine("Unknown latitude and longitude.")
    End If
End Sub

適用於