SwiftUI Maps & Location: Fundamentals
Mar 15 2022 · Swift 5.5, iOS 15, Xcode 13
Part 1: MapKit
Leave a rating/review
Notes: 01. Introduction
The student materials have been reviewed and are updated as of January, 2022.
Hey, what’s up everybody. This is Brian and Welcome to Core Location and Map Kit video tutorial series. Core Location and Map Kit are two very powerful frameworks that you can incorporate into your app and in this video tutorial series, you’ll be learning how to do this.
What’s the big saying in real estate? Location, location, location. Not surprisingly, these few words are proving just important to app developers as well. As smart phones grow ubitiqious, the 2D landscape of apps are being entangled with the 3D world around it. Location not only tells users where they are, where they’ve been, and where they are going, but provides opportunities in the context around them. Think of it … two people without any connection outside an app can be united to form new relationships all through location.
With a mere tap on your phone, you can get a ride from services like Uber or Lyft.
Meet ups can now be as spontaneous as walking into a building and being notified of any surrounding people who share common interests.
You can even follow a trail of GPS coordinates to the middle of nowhere to discover “treasure chests” called geocaches where total strangers share items with one another. This is all done through location and thankfully iOS comes loaded with some powerful location and map features. For something so integral to mobile usage, it’s funny to think back at a time when MapKit was actually farmed out to a third party.
Back in the old days, that is pre iOS 6, all map related features were provided by Google. Google did a great job and people loved it, but Apple decided to provide their own frameworks instead of relying on a 3rd party. Apple feared that maps on iOS would not nearly be as up to date as its android counterparts. Also, Google Map’s didn’t provide turn by turn instructions. Users had to download an app off the app store to gain access to that feature.
So with the announcement of iOS 6 in WWDC 2012, Apple also announced Apple Maps to replace google Maps. This was met with some initial excitement, but after the rollout, Apple Maps ran into some very public growing pains.
Directions took users the wrong way, there were some very large scale maps inaccuracies, and in Satellite view, some streets even melted into goo. Thankfully MapKit has grown better and better with each release and these issues are a thing of past.
Now MapKit is quite a powerful API that can be run in your app as well as on the web by way of MapKit.js. MapKit is also provided free of charge. There’s no developer keys required. No credit cards to be handed over. You get everything right out of the box. That’s not to say you can go crazy with the service. In some cases, rate limits do apply and you’ll learn where as you progress through this course.
This series is broken up into two different parts. In the first part, you’ll learn about MapKit. You’ll learn how to include maps with your app and how to annotate them.
Afterwards, you’ll learn about Core Location. Core Location is the real muscle behind MapKit. It allows to determine locations, find distances between them, and a lot of other cool stuff which I’ll cover in just a moment.
This course is currently designed for beginning iOS developers. It is assumed you have a working knowledge of the Swift programming language. You should be comfortable working in SwiftUI as well. You also should know your way around Xcode and be able to deploy an app to a device. This course was produced using a Xcode 12 beta 5, using Swift version 5.3. There may be changes in the General Release of Xcode 12, but we’ll make sure to address those changes as they occur. If you run into issues, look for the author notes of each episode and then check the comments. We’ll do our best to resolve issues in a timely manner.
Now, in this upcoming part, we’ll be diving into MapKit. First you’ll learn how to add a Map to a SwiftUI app. Then you’ll learn how to control the interactions of a map as well. Then you’ll learn how to use SwiftUI to annotate your maps. Once you’ve explored the limits of a SwiftUI map, you’ll incorporate a UIKit version.
Whether to give directions to a store or providing discoverability options for like minded users, MapKit can bring your app to the next level. Of course, the very first step is to incorporate a map into your app which you’ll be doing in the next episode.