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 ...

Get Beginning iOS 5 Application Development 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.