Chapter 8. Maps and Location

In this chapter, you will learn how to harness the power of the iPhone’s Global Positioning System (GPS) inside your app. You will learn how to access the user’s location and plot it on a map. This chapter will also cover Map Kit, Apple’s framework for mapping and directions. With the information in this chapter, you will be able to tackle a location-based app in no time.

Providing information based on the user’s location is one of the most exciting features available while developing with an iOS device. Displaying the user’s location on a map is a two-step process. The first step is to gather the user’s location using Core Location. Core Location is a set of classes designed to work with the device’s GPS, cellular antenna, and WiFi antenna to provide the user’s location. Core Location is one of many optional frameworks provided by Apple. Frameworks are a set of classes and tools designed for a specific task. Let’s take Core Location as an example. It is a framework designed to work with location. Core Data is a framework designed to work with databases. These frameworks are optional, so they must be imported into the project to work properly.

The second step is to plot the user’s location on a map. Apple provides a framework called Map Kit to help draw and manage maps. Xcode 6 makes importing frameworks easy. To import Map Kit, click a project name in the Project Navigator. Then select the Capabilities tab and scroll down to Maps. Toggle the Maps switch ...

Get Introducing iOS 8 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.