O'Reilly logo

Beginning iOS 5 Application Development by Wei-Meng Lee

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

DISPLAYING MAPS AND MONITORING CHANGES USING THE MAP KIT

The iOS SDK ships with the Map Kit framework, a set of libraries that work with the Google Mobile Maps Service. You can use the Map Kit to display maps within your iOS application, as well as to display your current location. In fact, you can enable the Map Kit to track your current location simply by setting a single property, and the Map Kit will then automatically display your current location as you move.

In the following Try It Out, you will get started with the Map Kit. In particular, you will use the Map Kit to display your current location on the map.

TRY IT OUT: Getting Started with Map Kit

image

  1. Using Xcode, create a Single View Application (iPhone) project and name it Maps. You also need to use the project name (Maps) as the Class Prefix and ensure that you have the Use Automatic Reference Counting option unchecked.
  2. Add the MapKit.framework to the Frameworks folder of the project (see Figure 20-1).

    image

    FIGURE 20-1

  3. Select the MapsViewController.xib file to edit it in Interface Builder.
  4. Populate the View window with the following views (see Figure 20-2):
    • Map View
    • Round Rect Button (label it “Show My Location”; be sure to do this correctly, including capitalization)
  5. In the MapsViewController.h file, add the following bold ...

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