Chapter 11. Geolocation and Mapping
The Core Location API is one of the great things about the iPhone and iPod touch platforms, but until the arrival of the MapKit Framework in the 3.0 SDK, it was actually quite hard to take that location-aware goodness and display it on a map. The arrival of the MapKit framework has simplified this enormously.
Let’s work through a few example applications to get you familiar with the framework.
User Location
Note
You can follow along while I build this application in a screencast available on the book’s website.
The first thing we’re going to do is build a simple application to answer the question “Where am I?”. Start a new iPhone project in Xcode, select a view-based template, and name the project “WhereAmI” when prompted.
Next, you need to add the MapKit and Core Location frameworks to your new project. You do not need the Core Location framework to work with MapKit, but we’re going to use it later in the chapter, so we may as well add it now:
Right-click on the Frameworks group in the Groups & Files pane in Xcode and select Add→Existing Frameworks. In the pop-up window that appears, select the MapKit framework and click Add.
Do this a second time, but for the Core Location framework.
Warning
If you have upgraded your Xcode (and iPhone SDK) distribution in the middle of developing a project, MapKit.framework may not show up in the list of frameworks Xcode presents in the framework selection pop up. In this case, you may be able to resolve the problem by ...
Get Learning iPhone Programming 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.