Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

6. Core Location and Maps > 6.1. Creating a Map View

6.1. Creating a Map View

Problem

You want to instantiate and display a map on a view.

Solution

Create an instance of the MKMapView class and add it to a view or assign it as a subview of your view controller. Here is the sample .h file of a view controller that creates an instance of MKMapView and displays it full-screen on its view:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface Creating_a_Map_ViewViewController : UIViewController

@property (nonatomic, strong) MKMapView *myMapView;

@end

This is a simple root view controller with a variable of type MKMapView. Later in the implementation of this view controller (.m file), we will initialize the map and set its type to Satellite, like so:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial