From the course: Advanced iOS App Development: MapKit & Core Location

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Polyline overlays

Polyline overlays - iOS Tutorial

From the course: Advanced iOS App Development: MapKit & Core Location

Start my 1-month free trial

Polyline overlays

- [Instructor] You've used a circle overlay to show an area around a restaurant. You can use lines in your overlays in several ways. You can make closed shapes with the MK polygon and lines with the MK polyline using their appropriate renderers, MK polygon renderer and MK polyline renderer. We'll use MK polyline in our application since we'll be using it later for directions. Close the app. Go back to Xcode in the view controller class. Let's make a line between the two Beverly Hills restaurants. I'll grab my coordinates from the annotations so I have less to look up. Make a new function above the add delivery overlay method. We'll call it func. We'll call it addpolylines. Now in this function I'd be tempted to use map view annotations to get my coordinates like I did with the add delivery overlay, but that would be a mistake. That's a set not an array. The index and the location would change each use of the app. I have to find the correct annotations. Instead I'm going to use pizza…

Contents