The Navigation SDK for iOS is only available upon request. Contact us to get started.
Navigation functionality depends on knowing the user’s location.
Location updates are provided by the
LocationProvider. To obtain user location, you can use the default location provider or set a custom provider.
Location updates along a route can also be simulated for testing purposes.
LocationProvider. Upon construction the delay of the location updates can be set. The delay will be set in seconds. If a delay is set, a delay-based simulation strategy will be used. If no delay is set, a timestamp-based simulation strategy will be used.
The delay-based strategy gives every next location update after the provided delay in seconds. The timestamp-based strategy uses the difference in time between the timestamps associated with the coordinates to decide the pace of updates. For timestamp-based simulation, use a ttp file to update the coordinates.
To create the simulated location provider, use:
let timeStampBasedProvider = SimulatedLocationProvider(delay: nil)let delayBasedProvider = SimulatedLocationProvider(delay: 1.0)
The provider simulates location updates using the provided locations. Locations can be provided by calling
updateCoordinates with an array of coordinates. For example, the geometry of a
Route can be used.
let coordinates: [CLLocationCoordinate2D] = route.geometryengineUpdatedWithCoordinates.updateCoordinates(coordinates)
Locations can also be provided using a ttp file or a gpx file:
timeStampBasedEngine.updateLocationsFromTTPFile(path: "<TTP_FILE_PATH>")delayBasedEngine.updateCoordinatesFromGPXFile(path: "<GPX_FILE_PATH>")
When updating the coordinates it is possible to define if the location provider should use interpolation or not. When updating coordinates with a gpx file or ttp file, the default is false. When updating coordinates with an array of coordinates the default is true. To override the default setting, use:
1timeStampBasedEngine.updateLocationsFromTTPFile(path: "<PATH>", interpolate: true)2delayBasedEngine.updateCoordinatesFromGPXFile(path: "<PATH>", interpolate: true)3engineUpdatedWithCoordinates.updateCoordinates(coordinates, interpolate: false)
Interpolation should be used if the successive locations are not close enough together. The main use case of this strategy is simulating from a route, because the coordinates are too far away from each other for smooth rendering.
LocationProvider used for navigation is initially specified using the NavigationConfiguration object. However, you can change the provider responsible for location updates at any time. For example, you can switch to simulated locations even if the navigation was started with the user location.
1let navigation = Navigation(configuration: configuration)2navigation.start()3let simulatedLocationProvider = SimulatedLocationProvider(delay: 0.5)4navigation.locationProvider = simulatedLocationProvider