Chapter 16
Working with Maps

The longer it takes to develop, the less likely it is to launch.

-Jason Fried, Basecamp

The MapKit framework provides APIs for developers to display maps, navigate through maps, add annotations for specific locations, add overlays on existing maps, etc. With the framework, you can embed a fully functional map interface into your app without any coding.

The latest version of the framework also allows developers to provide pin customization, transit, and flyover support. With the built-in API, developers are given with the option to customize the annotation. I will go over some of these features with you. In particular, you will learn a few things about the framework:

  • How to embed a map in a view and a table view cell
  • How to translate an address into coordinates using Geocoder
  • How to add and customize a pin (i.e. annotation) on map
  • How to customize an annotation

To give you a better understanding of the MapKit framework, we will add a map feature to the FoodPin app. After the change, the app will display a small map view in the detail screen. When a user taps that map view, the app will further bring up an interactive map that takes up the whole screen.

Cool, right? It's gonna be fun. Let's get started.

Using MapKit Framework

By default, the MapKit framework is not bundled in the Xcode project. To use it, you have to first add the framework and bundle it in your project. But you don't need to do it manually. Xcode has a capability section that lets you configure frameworks for various Apple technologies such as Maps and iCloud.

In the project navigator, select the FoodPin project and choose the FoodPin target. You can then enable the Maps feature by clicking the + Capabilities button. Just look for Maps and double click it. Xcode will automatically configure the project to use the MapKit framework.

Figure 16-1. Enabling Maps in your Xcode project
Figure 16-1. Enabling Maps in your Xcode project

To access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.

results matching ""

    No results matching ""