GeoCoordinateWatcher.Position Proprietà

Definizione

Ottiene GeoCoordinate che indica la posizione corrente.Gets the GeoCoordinate which indicates the current location.

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)

Valore della proprietà

GeoCoordinate che indica la posizione corrente.The GeoCoordinate which indicates the current location.

Implementazioni

Esempi

Nell'esempio seguente, la Location proprietà Position della proprietà viene salvata in un GeoCoordinate oggetto.In the following example, the Location property of the Position property is saved in a GeoCoordinate object. I campi Latitudine e Longitudine di GeoCoordinate vengono stampati se noti.The latitude and longitude fields of the GeoCoordinate are printed if they are known.

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

Si applica a