Skip to content


This section explains the use of route computing functionality including multiple waypoints and alternate routes within an iOS app.

Car and Pedestrian Routing

The Sygic Maps SDK for iOS supports route calculation with multiple waypoints, optimized for walking or driving. A route describes a path between at least two waypoints, the starting point and the destination, with optional intermediate waypoints in between.

Applications can provide route information to users in two ways:

  • A line rendered on a map that displays a connecting path between all waypoints
  • Turn-by-turn directions in text format


Represents the routing options (represented by the SYRoutingOption "Enums") that are applicable for the selected route

SYTransportmode property of SYRoutingOptions class provides following modes of routing:

  • Car
  • Pedestrian
  • Unknown

The following example shows how to calculate a route from startpoint to endpoint. It's based on example from Getting Started, with added createRoute() and SYRoutingDelegate.

import UIKit
import SygicMaps

class ViewController: UIViewController {

    var mapView: SYMapView!
    var mapObjects = [SYMapObject]()
    lazy var routing = SYRouting()

    override func viewDidLoad() {

        if SYContext.isInitialized() {
        } else {
            let center = NotificationCenter.default
            var token: NSObjectProtocol?
            token = center.addObserver(forName: .DidInitSygicMaps, object: nil, queue: nil) { [weak self] (_) in


    func setupMapView() {
        mapView = SYMapView(frame: view.bounds) = 17 = 0 = SYGeoCoordinate(latitude: 48.145810, longitude: 17.126420)

        mapView.translatesAutoresizingMaskIntoConstraints = false

            mapView.topAnchor.constraint(equalTo: view.topAnchor),
            view.bottomAnchor.constraint(equalTo: mapView.bottomAnchor),
            mapView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            view.trailingAnchor.constraint(equalTo: mapView.trailingAnchor)

    func createRoute() {
        routing.delegate = self

        let start = SYWaypoint(
            position: SYGeoCoordinate(latitude: 48.158080, longitude: 17.127770),
            type: .start,
            name: nil
        let end = SYWaypoint(
            position: SYGeoCoordinate(latitude: 48.373560, longitude: 17.598250),
            type: .end,
            name: nil

        // Optionally: create an instance of SYRoutingOptions for configuring computing of a route
        let routingOptions = SYRoutingOptions()
        routingOptions.transportMode = .car // For other options see SYTransportMode
        routingOptions.routingType = .fastest // For other options see SYRoutingType

        let request = SYRouteRequest(start: start, destination: end, options: routingOptions, viaPoints: nil)
        routing.computeRoute(for: request)

extension ViewController: SYRoutingDelegate {
    func routing(_ routing: SYRouting, didComputePrimaryRoute route: SYRoute?) {
        guard let route = route else { return }

        // remove old routes and labels from the map

        // add new route to the map
        mapObjects = [
            SYMapRoute(route: route, type: .primary),
            SYMapRouteLabel(text: "My route", textStyle: nil, placeOn: route)

        // zoom out with animation to display full route
            with: UIEdgeInsets.init(top: 0.15, left: 0.15, bottom: 0.15, right: 0.15),
            duration: 1.0,
            curve: .accelerateDecelerate,
            completion: nil

iOS Routing


You can use SYWaypoint to add waypoint(s) to route calculation.

// Create SYWaypoint with type .via
let waypoint = SYWaypoint(position: fromCoordinate, type: .via, name: nil)

// Pass it to SYRouteRequest
let request = SYRouteRequest(start: start, destination: end, options: routingOptions, viaPoints: [waypoint])

Route Serialization

Route serialization is a feature that allows users to use the new SYRoute method serializeRoute to serialize a route into NSData, which can then be saved as a file. This is useful when a user would like to recover from a crash during navigation or when a user would like to transfer a route from one device to another.

The following is an example of how to invoke the serialization APIs:

// Serialization
let serializer = SYRouteSerializerBrief()
if let jsonSerializedRoute = serializer.serializeRoute(route) {

    // Computing route from JSON
    routing.computeRoute(fromJson: jsonSerializedRoute)