Skip to content

Navigation module

Jakub Kracina edited this page Sep 6, 2019 · 7 revisions

Navigation module offers you navigating from point A to point B. You must calculate route and then you can navigate on that route. The module provides current speed, speed limits, signposts, lane assistance, etc.

Inputs and outputs of the module serve as quick look for possibilities you can do with the module. For more information look at code and its documentation.

Inputs

route: SYRoute? - route you are navigate on, if it's nil, you just drive without the road
preview: Bool - with preview on, navigation is simulated
useLaneAssist: Bool - simulates road lanes to help driver stay on correct side of the road
useCurrentSpeed: Bool - shows current speed of vehicle
useSpeedLimit: Bool - shows speed limits on roads if available
useInfobar: Bool - shows infobar with custom information, for example ETA, time, etc.
leftInfobarButton: SYUIActionButton? - left button in infobar
rightInfobarButton: SYUIActionButton? - right button in infobar
instructionsType: Enum (.direction, .signpost, .none) - type of view for instructions, .direction shows direction arrow, distance, street name and .signpost also simulates signposts on the road
units: Enum (.kilometers, .milesFeet, .milesYards) - units used in current speed etc.
audioEnabled: Bool - audio instructions

Outputs

navigationController(_ controller: SYMKNavigationViewController, didUpdate mapState: SYMKMapState)
Calls every time map state is updated

navigationController(_ controller: SYMKNavigationViewController, didStartNavigatingWith mapRoute: SYMapRoute)
Navigation start event

navigationControllerDidStopNavigating(_ controller: SYMKNavigationViewController)
Navigation stop event

navigationController(_ controller: SYMKNavigationViewController, didFindBetterRoute route: SYAlternativeRoute)
Better alternative route was found

navigationController(_ controller: SYMKNavigationViewController, didPassWaypoint: SYWaypoint, at index: UInt)
If route contains waypoints, this is called after passing some.

navigationControllerDidReachFinish(_ controller: SYMKNavigationViewController)
Navigation reached finish

Examples

Navigation demo

Example with predefined route and preview mode enabled.

Preview

It's possible to initiate and present empty navigation controller without route and start navigating after.

Code

let navigation = SYMKNavigationViewController()
...
// obtain SYRoute from SYRouting
...
navigation.startNavigation(with route: SYRoute, preview: true)

Or initiate controller with existing SYRoute and navigation starts automatically.

Code

let navigation = SYMKNavigationViewController(with: existingRoute)

Sample

Navigation from current location

Example tries to compute route from your current location to predefined destination in Rome and start navigating. In this case, preview mode is disabled.

Sample

Navigation instructions type

This sample interactively demonstrates all available instructions types. You can choose between simple direction or more complex signpost type or turn instructions off completely by selecting none.

Preview

Code

let navigation = SYMKNavigationViewController()
navigation.instructionsType = .signpost

Instruction types

  • .none
  • .direction
  • .signpost

Sample

Custom infobar buttons

Example how to change predefined buttons inside infobar.

Preview

Code

let superCustomButton = SYUIActionButton()
// any button customizations
...
let navigation = SYMKNavigationViewController()
navigation.leftInfobarButton = superCustomButton

Sample