Muokkaa

Jaa


GeoCoordinateWatcher.Position Property

Definition

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)

Property Value

The GeoCoordinate which indicates the current location.

Implements

Examples

In the following example, the Location property of the Position property is saved in a GeoCoordinate object. 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)
    {
        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

Applies to