O'Reilly logo

iPhone and iPad App 24-Hour Trainer by Gene Backlin, Abhishek Mishra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 35

Introducing Map Kit

In the previous lesson you learned how to locate a device using Core Location. In this lesson you learn how to integrate a map within your application.

The Map Kit framework provides the MKMapView class for adding maps into your views. Map Kit also provides additional classes for annotating the map. The Map Kit framework uses Google’s map service internally. Using a class within this framework binds you to the Google Maps/Google Earth terms of service. You can find these at http://code.google.com/apis/maps/iphone/terms.html.

The Map Kit framework is often used in conjunction with the Core Location framework, neither of which are included in any of the standard iOS application templates. To use these frameworks in your code you need to add them manually to your project. You can do this from the Project Settings page in Xcode. Select the Project node in the project navigator to display the settings page. On the settings page, switch to the Build Phases tab and click the + button under the Link Binary With Libraries category. Select the Map Kit framework from the list of available frameworks (Figure 35-1). Repeat this step for the Core Location framework.

You can add a map view to an existing view controller or storyboard using the Object library. Simply drag an instance of a map view and create an outlet for it in the view controller class.

The map view handles zooming and scrolling automatically. You can use the Attributes inspector to choose from ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required