Geolocator
Namespace: XPlat.Device.Geolocation
Provides access to the current geographic location.
Supported platforms
Platform
Version
Xamarin.Android
9.0
Xamarin.iOS
1.0
UWP
10.0.16299
Example
This example shows how to use the Geolocator class to retrieve the device's location.
Constructors
Geolocator(Android.Content.Context) - Android
Parameters
context (Android.Content.Context)
The current Android context.
Properties
LastKnownPosition
Gets the last known position recorded by the Geolocator.
ReportInterval
Gets or sets the requested minimum time interval between location updates, in milliseconds. If your application requires updates infrequently, set this value so that location services can conserve power by calculating location only when needed.
MovementThreshold
Gets or sets the distance of movement, in meters, relative to the coordinate from the last PositionChanged event, that is required for the Geolocator to raise a PositionChanged event.
LocationStatus
Gets the status that indicates the ability of the Geolocator to provide location updates.
DesiredAccuracy
Gets or sets the accuracy level at which the Geolocator provides location updates.
DesiredAccuracyInMeters
Gets or sets the desired accuracy in meters for data returned from the location service.
Methods
GetGeopositionAsync()
Starts an asynchronous operation to retrieve the current location of the device.
Returns
An asynchronous operation that, upon completion, returns a Geoposition marking the found location.
GetGeopositionAsync(TimeSpan, TimeSpan)
Starts an asynchronous operation to retrieve the current location of the device.
Parameters
maximumAge (TimeSpan)
The maximum acceptable age of cached location data.
timeout (TimeSpan)
The timeout.
Returns
An asynchronous operation that, upon completion, returns a Geoposition marking the found location.
RequestAccessAsync()
Requests permission to access location data.
Returns
A GeolocationAccessStatus that indicates if permission to location data has been granted.
Events
PositionChanged
Raised when the location is updated.
StatusChanged
Raised when the ability of the Geolocator to provide updated location changes.
Last updated