Start navigating

The Sygic iOS SDK supports navigation on pedestrian and car routes. Using this feature, your app can check the current device position against a calculated route and provide just-in-time navigational instructions, both as visual and voice instructions. Turn-by-Turn Navigation Mode, which takes the calculated route and matches the current position against the route is supported for walking and driving.

class NaviViewController: UIViewController, SYNavigationDelegate {

    func startNavigation(with route: SYRoute) {
        // Make self as delegate for SYNavigation to receive and handle SYNavigationDelegate calls
        SYNavigation.shared().delegate = self
        // Start navigation with route which you got from Route computing (see SYRouting)
        SYNavigation.shared().start(with: route)

        // Creating SYMapRoute object from SYRoute allows put visual representation of route onto the map
        let mapRoute = SYMapRoute(route: route, type: .primary)
        // Add SYMapRoute to SYMapView
        mapView.add(currentRoute)

        // Optionally: Set cameraMovemementMode (e.g. followGpsPosition to move map when vehicle moves)
        mapView.cameraMovementMode = .followGpsPosition
    }
}

SYNavigationDelegate protocol
SYNavigation notifies the client of navigation events through its delegates that implement the SYNavigationDelegate protocol. The delegate protocol include methods such as:

  • didUpdatePositionInfo: - Called when the current positionInfo has changed.
  • didUpdateSpeedLimit: - Called when the speed limit has changed.
  • didUpdateDirection: – Called when current instruction has changed.
  • didUpdateSignpost: - Called that the signopostInfo has changed.
  • didUpdateRadar: - Called that the radar on the route has been updated.
  • didUpdateSharpCurve: - Called when a danger turn is ahead on current route.
  • didPassWaypointWithIndex: - Called when turn-by-turn navigation waypoint is passed.
  • navigationManagerDidReachFinish: - Called when turn-by-turn navigation destination is reached.
  • didFindBetterRoute: - Called when better route has been found.
  • didUpdateHighwayExit: - Called when hihgway exit info has changed. Event does not fire when route is calculated.
  • didUpdateRoute: - Called when current navigation route is changed or removed.
  • didUpdateTransportMode: - Called when transport mode has changed. For example you switch from car to pedestrian.
  • didUpdateOnRouteInfo: - Called when position on current navigation route has changed.

SYNavigationAudioFeedbackDelegate protocol
To get audio notifications and voice navigation, you have ti listen to SYNavigationAudioFeedbackDelegate. If you set these to NO, audio warnings will be disabled.

  • shouldPlayWarningAudioFeedback: - Called when navigation manager has warning audio feedback is ready to play.
  • shouldPlaySpeedLimitAudioFeedback: - Called when speed limit warning audio feedback is ready to play.
  • shouldPlayBetterRouteAudioFeedback: - Called when better route audio feedback is ready to play.
  • shouldPlayTrafficAudioFeedback: - Called when traffic change audio feedback is ready to play.
  • shouldPlayInstructionAudioFeedback - Called when navigation instruction audio feedback is ready to play.

Map Matching During Navigation

Map Matching is automatically enabled in both navigation mode and tracking mode. In simulation mode, the map-matched position is simulated along the route with a user-defined speed.

Audio Warnings

Sygic Mobile SDK enables you to set custom audio notifications for warnings. If the methods of above mentioned SYNavigationAudioFeedbackDelegate are set to YES, there will be played some default set audio notifications. To use your custom ones, you have to use SYAudioSettings class. SYAudioSettings class provides a possibilities to set a custom voice for various cases. You can choose between prerecorded audio files (OGG or WAVE format) or TTS voice. See the SYAudioSettings API reference for more info.

Following example shows, how to set an custom TTS voice, when you exceed the speed limit.

SYAudioSettings* audioSettings = [SYAudioSettings new];
    audioSettings.speedLimitWarning.mode = SYAudioWarningModeUseTts;
    audioSettings.speedLimitWarning.ttsText = @"Slow down!";

If you would like to use custom precorded audio file, you need to choose it from path:

SYAudioSettings* audioSettings = [SYAudioSettings new];
    audioSettings.speedLimitWarning.warningSoundPath = [[NSBundle mainBundle] pathForResource:@"/example/example/example" ofType:@"wav"];

Voice Instructions

Voice instructions are available in the Sygic SDK as voice packages. Voice packages are available in two forms: pre-packaged or downloadable through the voice catalog. You can set a voice package to be used for navigational instructions. However, if a package is not set, the Sygic SDK sets the navigation voice language to US English, which is pre-packaged with the Sygic SDK.

The SYVoicePackage class encapsulates spoken voices that can be used for navigation guidance. It contains information such as name, gender, and the spoken language. This information can be accessed through its class properties.

A list of loaded SYVoicePackage instances can be accessed by using the SYVoiceCatalog singleton instance. Multiple voice package can be loaded to the device, but only one can be selected for navigation voice playback. A SYVoicePackage can be used through the voicePackage property. Each SYVoicePackage is represented by a unique ID in the packageId property.

The Sygic SDK supports two types of voice packages: text-to-speech or pre-recorded. Pre-recorded voice skins provide basic maneuver instructions, such as "turn right in 100 meters", while text-to-speech voices also support spoken street names, such as "turn right in 100 meters onto Wall Street".

The following is an example of how to use a SYVoicePackage with the navigation manager:

class VoicesViewController: UIViewController, SYVoiceCatalogDelegate {
    var voicePackages: [SYVoicePackage]()

    func viewDidLoad() {
        // Make self as delagate for SYVoiceCatalog to receive and handle responses. 
        SYVoiceCatalog.shared().delegate = self

        // Get a list of all available and already installed voice packages
        SYVoiceCatalog.shared().getAvailableVoicePackages { (_, availablePackages) in
            // voicePackages contains installed packages and packages available to install from server
            self.voicePackages = availablePackages
        }

        // Optionally: If you want just installed packages
        SYVoiceCatalog.shared().getInstalledPackages { (_, installedPackages) in
            self.voicePackages = installedPackages
        }
    }

    func downloadPackage(with index: Integer) {
        let voicePackage = voicePackages[index]
        // Download and install voice package to device
        SYVoiceCatalog.shared().installVoicePackage(voicePackage)
    }

    // MARK: - SYVoiceCatalogDelegate

    // Called when voice package did install.
    func voiceCatalog(_ voiceCatalog: SYVoiceCatalog, didInstallVoicePackage package: SYVoicePackage, result: SYPackageInstallResult, from task: SYTask) {
        // Set the downloaded voice as your current
        SYVoiceCatalog.shared().setCurrentVoice(voicePackage)
    }
}

If the voice is set, in navigation mode the voice instructions are played automatically.

This is a list of the potential TTS languages that are supported. Actual audio playback depends on the supported languages in the user's installed version of iOS.

  • English (US)
  • English (UK)
  • English (AUS)
  • French (France)
  • French (Canada)
  • German
  • Belgian
  • Bahasa Indonesia
  • Hungarian
  • Dutch
  • Arabic
  • Finnish
  • Spanish (Spain)
  • Spanish (Mexico)
  • Italian
  • Norwegian
  • Portugese (Portugal)
  • Portugese (Brazil)
  • Russian
  • Swedish
  • Finnish
  • Danish
  • Korean
  • Hindi
  • Chinese (Taiwanese Mandarin)
  • Chinese (Hong Kong Mandarin)
  • Turkish
  • Czech
  • Polish

Traffic

The Sygic iOS SDK offers real-time traffic flow and congestion overlays. Traffic information can be displayed on the SYMapView (where available) by calling the enableTraffic method. While the Sygic SDK requires a network data connection to download real time traffic information, the visualization may continue to be displayed even if a connection is lost - until the traffic events expire, or the visibility is toggled.

// To enable (or disable) traffic
SYTraffic.shared().enabled = true // or false
Map view with traffic

For further information see the SYTraffic reference.

Signposts

This section provides guidelines on how to use the Sygic Mobile SDK Signpost object to present visual maneuver instructions which match with the audible voice instruction during turn-by-turn guidance. Signs represent textual and graphic information posted along roads. The information is always represented as text, but may originate from a graphical icon. Signpost information may be used for route guidance (both audible and visual guidance) and map display. A navigation system may prefer using the signpost text rather than the street/ramp name as the latter may not always match what is on the sign in reality and may confuse a user. The signpost feature supports the user navigating through complex situations and provides a conformation for a maneuver by presenting the same direction information as shown on the street signs in reality.

Based on the map attributes, the Sygic iOS Mobile SDKs aggregate the following information into a Signpost object:

  • Route number
  • Exit number
  • Exit name
  • Pictogram
  • Place name

Following example shows, how to get these information from the data structure, which the iOS SDK offers.

class NaviViewcontroller: UIViewController, SYNavigationDelegate {
    let route = SYRoute()

    // ...

    override func viewDidLoad() {
        // Make self a delegate for SYNavigation to receive signpost informations
        SYNavigation.shared().delegate = self
        // Start navigation with your route (for details how to compute route and start navigation see Navigation and Routing sections)
        SYNavigation.shared().start(with: route)
    }

    // MARK: - SYNavigationDelegate

    func navigation(_ navigation: SYNavigation, didUpdateSignpost signpostInfo: [SYSignpost]?) {
        // Get first signpost from signpostInfo array
        guard let firstSignpost = signpostInfo?.first else { return }

        // Text color of the signpost
        let textColor = firstSignpost.textColor
        // Background color of the signpost
        let backgroundColor = firstSignpost.backgroundColor
        // Distance to signpost from current position
        let distanceToSignpost = firstSignpost.distance

        // Single signpost contains multiple SYSignpostElement objects which contains detail informations about specific signpost
        for element in firstSignpost.elements {
            switch element.type {
            case .placeName, .streetName, .otherDestination:
                if let text = element.text {
                    // Name of place, street or other destination
                }
            case .routeNumber:
                if let routeNumber = element.text {
                    // Route number
                }
            case .exitName:
                if let exitName = element.text {
                    // Exit name
                }
            case .exitNumber:
                if let number = element.text {
                    // Exit number
                }
            case .pictogram:
                // Pictogram (e.g. Airport, Hospital, ...)
                let pictogram = element.pictogram
            case .lineBreak:
                break
            }
        }
    }
}

Directions

To provide more detailed information in signpost, you can display the direction which the user should follow. The Directions feature allows developers to define and display routes between a start and a destination point within their application. NavigationManager.OnDirectionListener can return following information:

  • Direction distance
  • Next direction distance
  • Maneuver type - see the all available ManeuverTypes
  • Road name
  • Next road name

Following example shows, how to get these information from the data structure, which the iOS SDK offers.

class NaviViewcontroller: UIViewController, SYNavigationDelegate {
    let route = SYRoute()

    // ...

    override func viewDidLoad() {
        // Make self a delegate for SYNavigation to receive direction informations
        SYNavigation.shared().delegate = self
        // Start navigation with your route (for details how to compute route and start navigation see Navigation and Routing sections)
        SYNavigation.shared().start(with: route)
    }

    // MARK: - SYNavigationDelegate

    func navigation(_ navigation: SYNavigation, didUpdateDirection instruction: SYInstruction?) {
        guard let instruction = instruction else { return }

        if let primaryManeuver = instruction.primaryManeuver {
            let distanceToManeuver = primaryManeuver.distanceToManeuver // in meters
            let instructionType = primaryManeuver.type // e.g. left, right, straight, u-turn, ...
            let currentRoadName = primaryManeuver.road?.roadName
            let nextRoadName = primaryManeuver.nextRoad?.roadName

            print("Distance to instruciton of type \(instructionType) on the road \(currentRoadName) is \(distanceToManeuver). Next road is \(nextRoadName)")
        }

        // Optionally: handle secondary maneuver similar like the primary one
        if let secondaryManeuver = instruction.secondaryManeuver {

        }
    }

}

With these data now you just have to draw them into your view and create your own signposts and directions. For example like this:

Signpost

Junction View

Junction view is one of our advanced safety features. When you are approaching a complex highway intersection, a full screen diagram of the intersection will appear on the screen showing you in detail which lane you should be in. It guides you into the correct lane to make driving easier, safer and less stressful.

class NaviViewcontroller: UIViewController, SYNavigationDelegate {
    let route = SYRoute()

    // ...

    override func viewDidLoad() {
        // Make self a delegate for SYNavigation to receive direction informations
        SYNavigation.shared().delegate = self
        // Start navigation with your route (for details how to compute route and start navigation see Navigation and Routing sections)
        SYNavigation.shared().start(with: route)
    }

    // MARK: - SYNavigationDelegate

    func navigation(_ navigation: SYNavigation, didUpdateSignpost signpostInfo: [SYSignpost]?) {
        // Get junctionInfo from first signpost if available
        guard let junctionInfo = signpostInfo?.first?.junctionInfo else { return }

        let turnType = junctionInfo.turnType // e.g. exit, bifurcation, road exit
        let turnDirection = junctionInfo.turnDirection // left, right or none
        let fromLanes = junctionInfo.fromLanesCount // number of lanes before junction
        let toLanesLeft = junctionInfo.toLeftLanesCount // number of lanes on the left side after junction
        let toLanesRight = junctionInfo.toRightLanesCount // number of lanes on the right side after junction

        // Optionally: get background type of upcoming junction info (e.g. city or forest)
        let background = junctionInfo.background
    }

}

Speed Limit

Speed limits indicate the legal speed for a vehicle. Depending on the country the values are given in mph or kph.
A speed limit has the following attributes:

Following example shows, how to get the current speed limit and it properties.

class NaviViewcontroller: UIViewController, SYNavigationDelegate {
    let route = SYRoute()

    // ...

    override func viewDidLoad() {
        // Make self a delegate for SYNavigation to receive direction informations
        SYNavigation.shared().delegate = self
        // Start navigation with your route (for details how to compute route and start navigation see Navigation and Routing sections)
        SYNavigation.shared().start(with: route)
    }

    // MARK: - SYNavigationDelegate

    func navigation(_ navigation: SYNavigation, didUpdate limit: SYSpeedLimit?) {
        guard let limit = limit else { return }

        let maximumAllowedSpeed = limit.speedLimit // maximum allowed speed
        let isInMunicipality = limit.isInMunicipality // represents if you are heading through Municipality
        let country = limit.country // america or rest of world
        let speedLimitUnits = limit.nativeUnits // kmh or mph
    }

}

Warning settings

Maybe you might want to change the settings to the warnings you get during navigation. SYWarningSettings is a base class for warning notification settings. To access these settings you have to use [SYNavigation sharedNavigation] instance.

SYPoiOnRouteSettings enables to change some POI on route settings.

  • maxCount - Poi on Route max search poi count.
  • maxDistance - Poi on Route max search distance.
[SYNavigation sharedNavigation].settings.poiOnRoute.maxDistance = 100;

SYDirectionSettings

  • nextDirectionDistance - Set the minimal distance between first end second instruction to be notified.
[SYNavigation sharedNavigation].settings.direction.nextDirectionDistance = 5;

SYSpeedLimitWarningSettings

  • speedLimitDiffInCity - Set diff speed above maximum allowed speed to be notified as speeding in city.
  • speedLimitDiff - Set diff speed above maximum allowed speed to be notified as speeding.
  • nextSpeedLimitDistance - Set next speed limit search distance ahead vehicle.
  • nextSpeedLimitDistanceInCity - Set distance how far will look for other speed limit ahead vehicle in city.
[SYNavigation sharedNavigation].settings.speedLimit.speedLimitDiffInCity = 5;

SYSpeedCameraWarningSettings

  • searchDistanceInCity - Set Speed cameras search distance ahead vehicle in city.
  • searchDistance - Set Speed cameras search distance ahead vehicle.

SYRailwayCrossingWarningSettings

  • searchDistance - Set Railway crossing search distance ahead vehicle.
[SYNavigation sharedNavigation].settings.railway.searchdistance = 300;

Report Incident

Our Speed Camera database consists of more than 60 000 fixed speed cameras, red light cameras and average speed checks all over the world. On top of that, the community reports tens of thousands of additional mobile speed cameras and police checks every day. So, if you want to help to make our database bigger, use following example to report an incident. As parameter you can choose in which direction it happened on the road.

  • location - The exact SYGeoCoordinate position of the incident.
  • type - Type of the incident you want to report. See the available SYIncidentType in API reference.
  • direction - Indicates whether the incident happened in my direction or opposite direction.
let coordinate = SYPositioning.shared().lastKnownLocation?.coordinate // Get last known position or provide your custom position
let type = SYIncidentType.camera // See SYIncidentType for more options
let direction = SYIncidentDirection.myDirection // or .oppositeDirection
SYNavigation.shared().reportIncident(atLocation: coordinate!, type: type, direction: direction)