GeoCoordinateWatcher.Position Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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 != 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
Applies to
Vertu í samstarfi við okkur á GitHub
Heimildina fyrir þetta efni er að finna á GitHub, þar sem þú getur líka búið til og farið yfir vandamál og sameinað beiðnir. Frekari upplýsingar er að finna í framlagshandbók okkar.
Athugasemdir
https://aka.ms/ContentUserFeedback.
Væntanlegt: Á árinu 2024 munum við hætta með GitHub-mál sem ábendingaleið fyrir efni og skipta því út fyrir nýtt ábendingakerfi. Frekari upplýsingar er að finna hér:Senda inn og skoða endurgjöf fyrir