Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Geolocation Class
Definition
- Namespace:
- Microsoft.Maui.Devices.Sensors
- Assembly:
- Microsoft.Maui.Essentials.dll
- Source:
- Geolocation.shared.cs
- Source:
- Geolocation.shared.cs
- Source:
- Geolocation.shared.cs
- Source:
- Geolocation.shared.cs
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.
Provides a way to get the current location of the device.
public ref class Geolocation abstract sealed
public static class Geolocation
type Geolocation = class
Public Class Geolocation
- Inheritance
-
Geolocation
Properties
| Name | Description |
|---|---|
| Default |
Provides the default implementation for static usage of this API. |
| IsEnabled |
Returns true when the device's location services are enabled |
| IsListeningForeground |
Indicates if currently listening to location updates while the app is in foreground. |
Methods
| Name | Description |
|---|---|
| GetLastKnownLocationAsync() |
Returns the last known location of the device. |
| GetLocationAsync() |
Returns the current location of the device. |
| GetLocationAsync(GeolocationRequest, CancellationToken) |
Returns the current location of the device. |
| GetLocationAsync(GeolocationRequest) |
Returns the current location of the device. |
| StartListeningForegroundAsync(GeolocationListeningRequest) |
Starts listening to location updates using the LocationChanged event or the ListeningFailed event. Events may only sent when the app is in the foreground. Requests Permissions.LocationWhenInUse from the user. |
| StopListeningForeground() |
Stop listening for location updates when the app is in the foreground.
Has no effect when not listening and IsListeningForeground
is currently |
Events
| Name | Description |
|---|---|
| ListeningFailed |
Occurs when an error during listening for location updates arises. When the event is fired, listening for further location updates has been stopped and no further LocationChanged events are sent. |
| LocationChanged |
Occurs while listening to location updates. |
Applies to
Feedback
Was this page helpful?
