Built-in location providers

VERSION 0.67.0
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. To get appropriate permissions, you must send authorization request by calling requestWhenInUseAuthorization() or requestAlwaysAuthorization() on the CLLocationManager instance respectively. Complete instructions to request location permissions on iOS can be found at Requesting authorization for location services.

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: LocationUpdateValidator = validationPolicy
let defaultLocationProvider: LocationProvider = DefaultCLLocationProvider(locationValidationPolicy: validationPolicy)