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
שתף איתנו פעולה ב- GitHub
ניתן למצוא את המקור לתוכן זה ב- GitHub, שם ניתן גם ליצור ולסקור בעיות ולמשוך בקשות. לקבלת מידע נוסף, עיין במדריך התורמים שלנו.