TomTomSDKLocationProvider
TomTomSDKLocationProvider
The LocationProvider module facilitates the delivery of location information within the TomTom Maps and Navigation SDKs. It provides functionality for obtaining real-time location updates and ensures that other modules can access this information effectively.
Functionalities
- LocationProvider provides a CLLocation for the TomTomMap, enabling accurate and timely location data for navigation.
- LocationUpdateObserver allows other components to receive location updates, ensuring that all relevant modules have access to current location information.
- DefaultCLLocationProvider implements the LocationProvider protocol using CLLocationManager as the GPS source. This implementation ensures reliable location updates based on GPS data.
- LocationUpdateValidator defines the policy for validating incoming location updates. The DefaultLocationValidator class serves as the default implementation for this validation, ensuring that only valid location data is processed.
- LocationEngineProviderType specifies the types of location sources, such as GNSS satellites and programmatically calculated locations based on road speed profiles.
API Overview
-
Implementation of
LocationProvider
that usesCLLocationManager
as a GPS source provider. Provides location updates and manages location-related services.This class is responsible for providing GPS location updates using the
CLLocationManager
. The class includes:- enable location and disable location updates
- manage observers and
validate location updates.
Important
This is a Public Preview API. It may be changed or removed at any time.
Declaration
Swift
public class DefaultCLLocationProvider : NSObject, ValidatingLocationProvider
-
Indicates if GPS is fixed or not as a result of
See moreLocationValidator
. Helps in determining the GPS status of the device, which can be either fixed or non-fixed.Declaration
Swift
public enum GPSStatus
-
A wrapper for the
CLLocation
class, encapsulating additional metadata for a location.Provides a more detailed representation of a location by including heading, provider type, and GPS status. Use this struct to enhance the information provided by a simple CLLocation object.
See moreDeclaration
Swift
public struct GeoLocation
-
The source that provides the location.
This enum defines the various sources that can provide location data for the
See moreGeoLocation
struct. It includes two types:gnss
(Global Navigation Satellite System), which represents location data from GNSS satellites, andsoftDR
, which represents location data that is programmatically calculated.Declaration
Swift
public enum LocationEngineProviderType
-
Part of the
MapMatchingResult
that represents a single matched position candidate.This struct encapsulates information about a position that has been matched to the map, including its location, an identifier, a probability score, and other relevant details. It is used in map matching results to provide detailed information about each matched position candidate.
See moreDeclaration
Swift
public struct MatchedLocation
-
Declares an observer that can receive location updates.
The
See moreLocationUpdateObserver
protocol is used to notify observers when a new location is available. Any object that wants to receive location updates should conform to this protocol and implement thedidUpdateLocation
method. This allows the observer to use the updated location for various purposes such as updating UI, navigation, etc.Declaration
Swift
public protocol LocationUpdateObserver : Observer
-
LocationProvider protocol used for providing a CLLocation for
TomTomMap
.The location provider additionally facilitates the delivery of location updates to other modules within the Maps and Navigation SDKs; modules can add observers to receive location updates. For
MapView
, TomTom provides an implementation based onCLLocationManager
. The default implementation can be replaced using:mapView.map.locationProvider = engine
Note
TheLocationProvider
protocol is responsible for providing location information but does not handle location authorization. It is the responsibility of the client to request and handle location authorization separately.Declaration
Swift
public protocol LocationProvider : AnyObject
-
The SimulatedLocationProvider provides simulated location updates to simulate driving on GPX/TTP tracks or route geometry.
When used in
DefaultTomTomNavigation
and it’s locations are generated from route geometry, please also set the same location provider inTomTomMap
. If not, then the navigation experience might not be smooth.Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public class SimulatedLocationProvider : ValidatingLocationProvider
-
Defines the policy for validating incoming location updates.
The
See moreLocationUpdateValidator
protocol specifies a method for validating incoming location updates. Implementations of this protocol can define custom validation logic to determine whether a new location update is valid based on the provided new and last known locations.Declaration
Swift
public protocol LocationUpdateValidator
-
LocationValidator
defines the interface for checking the validity of the location.The
See moreLocationValidator
protocol provides a method for validating a given location. Implementations of this protocol can define custom validation logic to determine whether a location is considered fixed (valid) or not based on the provided location and its source.Declaration
Swift
public protocol LocationValidator
-
DefaultLocationValidator is the default implementation of
LocationValidator
.The
See moreDefaultLocationValidator
class provides a default implementation for validating locations based on their horizontal accuracy. If the accuracy is within an acceptable range, the location is considered valid (GPS fixed), otherwise it is considered invalid (GPS not fixed).Declaration
Swift
public class DefaultLocationValidator : LocationValidator
-
Declaration
Swift
extension CLLocation