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

适用于