How to do it...

To get directions between a source and destination, perform the following steps:

  1. Let's continue using our demo to add a way to display directions between two locations.
  2. Go to storyboard and open our view controller to add a UIButton at the bottom with the title Directions. Add constraints to the button to stick it to the bottom, like this:
  1. Add an IBAction function, didClickOnDirections, to the button in ViewController.swift like this:
      @IBAction func didClickOnDirections(_ sender:
          AnyObject) { 
      } 
  1. Update the didClickOnDirections function like this:
 @IBAction func didClickOnDirections(_ sender: AnyObject) { let mapItem1 ...

Get iOS Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.