Skip to main content

Route Instructions

Last updated: June 10, 2026 | 5 minutes read

This example demonstrates how to use GEMKit in a UIKit application to calculate a route and display a detailed list of turn-by-turn instructions alongside any traffic events along the path.

Check the full implementation on GitHub.

Route Overview
List of Route Instructions

UI and Map Integration​

The view controller calculates the route and stores the first result for the instructions view:

ViewController.swiftView on GitHub
class ViewController: UIViewController {

var mapViewController: MapViewController?
var navigationContext: NavigationContext?
var trafficContext: TrafficContext?
var mainRoute: RouteObject?

override func viewDidLoad() {
super.viewDidLoad()

self.title = "Route Instructions"
self.navigationItem.largeTitleDisplayMode = .never

self.createMapView()
self.mapViewController!.startRender()
self.addRouteButton()
}

Calculating the Route​

The route is calculated with standard car preferences. The first result is saved on mainRoute for later access by the instructions screen:

ViewController.swiftView on GitHub
let preferences = RoutePreferencesObject.init()
preferences.setTransportMode(.car)
preferences.setRouteType(.fastest)

self.navigationContext = NavigationContext.init(preferences: preferences)

self.trafficContext = TrafficContext.init()
self.trafficContext?.setUseTraffic(.useOnline)

let waypoints = [
LandmarkObject.landmark(
withName: "San Francisco", location: CoordinatesObject.coordinates(withLatitude: 37.77903, longitude: -122.41991)),
LandmarkObject.landmark(
withName: "San Jose", location: CoordinatesObject.coordinates(withLatitude: 37.33619, longitude: -121.89058))
]

self.navigationContext?
.calculateRoute(withWaypoints: waypoints,
completionHandler: { [weak self] (results: [RouteObject]) in

guard let strongSelf = self else { return }

if !results.isEmpty {

strongSelf.mainRoute = results.first

strongSelf.mapViewController?
.presentRoutes(results, withTraffic: strongSelf.trafficContext, showSummary: true, animationDuration: 1000)
}
})

Showing Route Instructions​

Tapping the list button pushes the RouteInstructionsViewController, which iterates over segments and their instructions to build a table, also incorporating any traffic events:

RouteInstructionsViewController.swiftView on GitHub
func prepareModelData() {

guard self.route != nil else { return }

let scale = UIScreen.main.scale
let imgSize = CGSize.init(width: 40.0 * scale, height: 40.0 * scale)

let segmentList = self.route!.getSegments()

for segment in segmentList {

for routeInstruction in segment.getInstructions() {

let item = ModelDataItem.init()
item.routeInstruction = routeInstruction

if routeInstruction.hasTurnInfo() {
item.title = routeInstruction.getTurnInstruction()
}

if routeInstruction.hasFollowRoadInfo() {
item.description = routeInstruction.getFollowRoadInstruction()
}

if let turn = routeInstruction.getTurnDetails() {

item.image = turn.getTurnImage(
imgSize,
colorActiveInner: UIColor.black,
colorActiveOuter: UIColor.white,
colorInactiveInner: UIColor.lightGray,
colorInactiveOuter: UIColor.lightGray)
}

self.modelData.append(item)
}
}
}