Built-in location providers

VERSION 0.2.2746
PUBLIC PREVIEW

The Location module contains a LocationProvider interface that provides location updates to other modules of the Maps and Navigation SDKs. Those modules can subscribe to continue to receive location updates. You can also implement your own LocationProvider. See the instructions in the Custom Location Provider guide.

The Location module provides a predefined set of location providers:

Learn how to set up a project and add these location provider dependencies in the Quickstart.

DefaultCLLocationProvider

The DefaultCLLocationProvider updates user locations using the Apple Core Location services. Under the hood, it uses the CLLocationManager class as a GPS source provider.

Accuracy is set to the highest possible level, which uses additional sensor data to facilitate navigation apps.

The minimum distance (expressed in meters) a device must move horizontally before an update event is generated is set to the kCLDistanceFilterNone value. This constant indicates that all movement should be reported.

The location provider requires CLAuthorizationStatus.authorizedAlways or CLAuthorizationStatus.authorizedWhenInUse permissions. DefaultCLLocationProvider has built-in authorization request and authorization status verification.

Creating the DefaultCLLocationProvider object does not require any parameters to be provided.

let defaultLocationProvider: LocationProvider = DefaultCLLocationProvider()

The DefaultCLLocationProvider provides the DefaultLocationValidator class for checking if the location is fixed or not. If you want to set a custom validator, you have to create the object which adopts the LocationValidator protocol and pass this object to the provider.

let validationPolicy: LocationUpdateValidationPolicy = validationPolicy
let defaultLocationProvider: LocationProvider = DefaultCLLocationProvider(locationValidationPolicy: validationPolicy)