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
LocationEngine. To obtain user location, you can use the default location engine or set a custom engine.
Location updates along a route can also be simulated for testing purposes.
LocationEngine. 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 engine, use:
let timeStampBasedEngine = SimulatedLocationEngine(delay: nil)let delayBasedEngine = SimulatedLocationEngine(delay: 1.0)
The engine 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 engine 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.
LocationEngine used for navigation is initially specified using the NavigationConfiguration object. However, you can change the engine 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 simulatedLocationEngine = SimulatedLocationEngine(delay: 0.5)4navigation.locationEngine = simulatedLocationEngine