Transcript
Page 1: Session 300 - Getting Around Using Map Kit

These are confidential sessions—please refrain from streaming, blogging, or taking pictures

Session 300 and 310

Getting Around with Map Kit

Brady LawSoftware Engineer - Maps Client Team

Page 2: Session 300 - Getting Around Using Map Kit

Agenda

Page 3: Session 300 - Getting Around Using Map Kit

Agenda

• The new look of Map Kit

Page 4: Session 300 - Getting Around Using Map Kit

Agenda

• The new look of Map Kit• Launching Maps with MKMapItem

Page 5: Session 300 - Getting Around Using Map Kit

Agenda

• The new look of Map Kit• Launching Maps with MKMapItem• Developing routing apps

Page 6: Session 300 - Getting Around Using Map Kit

Powered by Apple MapsThe New Look of Map Kit

Page 7: Session 300 - Getting Around Using Map Kit
Page 8: Session 300 - Getting Around Using Map Kit
Page 9: Session 300 - Getting Around Using Map Kit
Page 10: Session 300 - Getting Around Using Map Kit

What does it take to get Apple Maps in my app?

Page 11: Session 300 - Getting Around Using Map Kit
Page 12: Session 300 - Getting Around Using Map Kit

Absolutely nothing.New Maps. Same API.

Page 13: Session 300 - Getting Around Using Map Kit
Page 14: Session 300 - Getting Around Using Map Kit

StandardMap Modes

Page 15: Session 300 - Getting Around Using Map Kit

SatelliteMap Modes

Page 16: Session 300 - Getting Around Using Map Kit

HybridMap Modes

Page 17: Session 300 - Getting Around Using Map Kit

Annotations

Page 18: Session 300 - Getting Around Using Map Kit

Overlays

Page 19: Session 300 - Getting Around Using Map Kit

With a Static MapPinch to Zoom

Page 20: Session 300 - Getting Around Using Map Kit

With a Static MapPinch to Zoom

Page 21: Session 300 - Getting Around Using Map Kit

With a Dynamic MapPinch to Zoom

Page 22: Session 300 - Getting Around Using Map Kit

With a Dynamic MapPinch to Zoom

Page 23: Session 300 - Getting Around Using Map Kit
Page 24: Session 300 - Getting Around Using Map Kit
Page 25: Session 300 - Getting Around Using Map Kit
Page 26: Session 300 - Getting Around Using Map Kit

Setting the Map Region

Page 27: Session 300 - Getting Around Using Map Kit

Setting the Map Region

• In iOS 5, region changes were adjusted to improve map display

Page 28: Session 300 - Getting Around Using Map Kit

Setting the Map Region

• In iOS 5, region changes were adjusted to improve map display-setRegion:

Page 29: Session 300 - Getting Around Using Map Kit

Setting the Map Region

• In iOS 5, region changes were adjusted to improve map display-setRegion:-setVisibleMapRect:

Page 30: Session 300 - Getting Around Using Map Kit

Setting the Map Region

• In iOS 5, region changes were adjusted to improve map display-setRegion:-setVisibleMapRect:

• No longer necessary in iOS 6

Page 31: Session 300 - Getting Around Using Map Kit

Heading Mode

Page 32: Session 300 - Getting Around Using Map Kit

Heading Mode

Static Map (iOS 5)

Page 33: Session 300 - Getting Around Using Map Kit

Heading Mode

Static Map (iOS 5)

Page 34: Session 300 - Getting Around Using Map Kit

Heading Mode

Static Map (iOS 5) Dynamic Map (iOS 6)

Page 35: Session 300 - Getting Around Using Map Kit

Heading Mode

Static Map (iOS 5) Dynamic Map (iOS 6)

Page 36: Session 300 - Getting Around Using Map Kit

The New Look of Map Kit

Page 37: Session 300 - Getting Around Using Map Kit

The New Look of Map Kit

• Map display APIs are the same

Page 38: Session 300 - Getting Around Using Map Kit

The New Look of Map Kit

• Map display APIs are the same• Improved map rendering

Page 39: Session 300 - Getting Around Using Map Kit

The New Look of Map Kit

• Map display APIs are the same• Improved map rendering• Re-link with iOS 6 to change regions with precision

Page 40: Session 300 - Getting Around Using Map Kit

The New Look of Map Kit

• Map display APIs are the same• Improved map rendering• Re-link with iOS 6 to change regions with precision• Test your apps!

Page 41: Session 300 - Getting Around Using Map Kit

A new API in iOS 6Launching Maps with MKMapItem

Page 42: Session 300 - Getting Around Using Map Kit

Why Launch Maps?Getting directions

Page 43: Session 300 - Getting Around Using Map Kit

Why Launch Maps?

Contacts/Bookmarks ExploreDrop a Pin

Page 44: Session 300 - Getting Around Using Map Kit

Introducing MKMapItem

Page 45: Session 300 - Getting Around Using Map Kit

Introducing MKMapItem

• Objective-C API

Page 46: Session 300 - Getting Around Using Map Kit

Introducing MKMapItem

• Objective-C API• Open Maps with one or more pins

Page 47: Session 300 - Getting Around Using Map Kit

Introducing MKMapItem

• Objective-C API• Open Maps with one or more pins• Jump directly into directions

Page 48: Session 300 - Getting Around Using Map Kit

Introducing MKMapItem

• Objective-C API• Open Maps with one or more pins• Jump directly into directions• Customize the map display

Page 49: Session 300 - Getting Around Using Map Kit

Opening an Item in Maps

Page 50: Session 300 - Getting Around Using Map Kit

Opening an Item in Maps

Page 51: Session 300 - Getting Around Using Map Kit

Opening an Item in Maps

MKPlacemark

Page 52: Session 300 - Getting Around Using Map Kit

Opening an Item in Maps

MKPlacemark

Location

Page 53: Session 300 - Getting Around Using Map Kit

Opening an Item in Maps

MKPlacemark

LocationAddress Dictionary

Page 54: Session 300 - Getting Around Using Map Kit

Opening an Item in Maps

MKMapItem

MKPlacemark

Page 55: Session 300 - Getting Around Using Map Kit

-openInMapsWithLaunchOptions:

Opening an Item in Maps

MKMapItem

MKPlacemark

Page 56: Session 300 - Getting Around Using Map Kit

-openInMapsWithLaunchOptions:

Opening an Item in Maps

MKMapItem

MKPlacemark

Page 57: Session 300 - Getting Around Using Map Kit

Opening an Item in Maps

MKMapItem *sfStore = [[MKMapItem alloc] initWithPlacemark:placemark];

Page 58: Session 300 - Getting Around Using Map Kit

Opening an Item in Maps

MKMapItem *sfStore = [[MKMapItem alloc] initWithPlacemark:placemark];

[sfStore openInMapsWithLaunchOptions:nil];

Page 59: Session 300 - Getting Around Using Map Kit

Opening an Item in Maps

Page 60: Session 300 - Getting Around Using Map Kit

Opening an Item in Maps

Page 61: Session 300 - Getting Around Using Map Kit

Adding Item Details

Page 62: Session 300 - Getting Around Using Map Kit

Adding Item Details

Page 63: Session 300 - Getting Around Using Map Kit

Adding Item Details

MKPlacemark

Page 64: Session 300 - Getting Around Using Map Kit

Adding Item Details

MKMapItem

+name+phone+url

MKPlacemark

Page 65: Session 300 - Getting Around Using Map Kit

-openInMapsWithLaunchOptions:

Adding Item Details

MKMapItem

+name+phone+url

MKPlacemark

Page 66: Session 300 - Getting Around Using Map Kit

-openInMapsWithLaunchOptions:

Adding Item Details

MKMapItem

+name+phone+url

MKPlacemark

Page 67: Session 300 - Getting Around Using Map Kit

MKMapItem *sfStore = [[MKMapItem alloc] initWithPlacemark:placemark];

sfStore.name = @"Apple Store - San Francisco";sfStore.phoneNumber = @"+14153920202";sfStore.url = [NSURL URLWithString:@"http://www.apple.com/retail/"];

[sfStore openInMapsWithLaunchOptions:nil];

Adding Item Details

Page 68: Session 300 - Getting Around Using Map Kit

Opening Multiple Map Items

Page 69: Session 300 - Getting Around Using Map Kit

Opening Multiple Map Items

Page 70: Session 300 - Getting Around Using Map Kit

Opening Multiple Items in Maps

Page 71: Session 300 - Getting Around Using Map Kit

Opening Multiple Items in Maps

MKMapItem

MKMapItem

MKMapItem

Page 72: Session 300 - Getting Around Using Map Kit

NSArray

Opening Multiple Items in Maps

MKMapItem

MKMapItem

MKMapItem

Page 73: Session 300 - Getting Around Using Map Kit

+openMapsWithItems:launchOptions:

NSArray

Opening Multiple Items in Maps

MKMapItem

MKMapItem

MKMapItem

Page 74: Session 300 - Getting Around Using Map Kit

+openMapsWithItems:launchOptions:

NSArray

Opening Multiple Items in Maps

MKMapItem

MKMapItem

MKMapItem

Page 75: Session 300 - Getting Around Using Map Kit

NSArray *storeItems = @[ sfStore, chestnutStore, bayStreetStore ];

Opening Multiple Map Items

Page 76: Session 300 - Getting Around Using Map Kit

NSArray *storeItems = @[ sfStore, chestnutStore, bayStreetStore ];

[MKMapItem openMapsWithItems:storeItems launchOptions:nil];

Opening Multiple Map Items

Page 77: Session 300 - Getting Around Using Map Kit

+openMapsWithItems:launchOptions: +openMapsWithItems:launchOptions: +openMapsWithItems:launchOptions:

-openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions:

Launch Options

Page 78: Session 300 - Getting Around Using Map Kit

+openMapsWithItems:launchOptions: +openMapsWithItems:launchOptions:

-openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions:

Launch Options

Page 79: Session 300 - Getting Around Using Map Kit

+openMapsWithItems:launchOptions: +openMapsWithItems:launchOptions:

-openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions:

Launch Options

Map type

Page 80: Session 300 - Getting Around Using Map Kit

+openMapsWithItems:launchOptions: +openMapsWithItems:launchOptions:

-openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions:

Launch Options

Map type

Coordinate region

Page 81: Session 300 - Getting Around Using Map Kit

+openMapsWithItems:launchOptions: +openMapsWithItems:launchOptions:

-openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions:

Launch Options

Map type

Coordinate region

Traffic

Page 82: Session 300 - Getting Around Using Map Kit

Map typeLaunch Options

NSDictionary *options = @{

};

Page 83: Session 300 - Getting Around Using Map Kit

Map typeLaunch Options

NSDictionary *options = @{ MKLaunchOptionsMapTypeKey :

[NSNumber numberWithInteger:MKMapTypeSatellite],

};

Page 84: Session 300 - Getting Around Using Map Kit

Coordinate regionLaunch Options

NSDictionary *options = @{ MKLaunchOptionsMapTypeKey :

[NSNumber numberWithInteger:MKMapTypeSatellite],

};

Page 85: Session 300 - Getting Around Using Map Kit

Coordinate regionLaunch Options

NSDictionary *options = @{ MKLaunchOptionsMapTypeKey :

[NSNumber numberWithInteger:MKMapTypeSatellite],

MKLaunchOptionsMapCenterKey : [NSValue valueWithMKCoordinate:regionCenter],

MKLaunchOptionsMapSpanKey : [NSValue valueWithMKCoordinateSpan:regionSpan]

};

Page 86: Session 300 - Getting Around Using Map Kit

Coordinate regionLaunch Options

NSDictionary *options = @{ MKLaunchOptionsMapTypeKey :

[NSNumber numberWithInteger:MKMapTypeSatellite],

MKLaunchOptionsMapCenterKey : [NSValue valueWithMKCoordinate:regionCenter],

MKLaunchOptionsMapSpanKey : [NSValue valueWithMKCoordinateSpan:regionSpan]

};

Page 87: Session 300 - Getting Around Using Map Kit

Coordinate regionLaunch Options

NSDictionary *options = @{ MKLaunchOptionsMapTypeKey :

[NSNumber numberWithInteger:MKMapTypeSatellite],

MKLaunchOptionsMapCenterKey : [NSValue valueWithMKCoordinate:regionCenter],

MKLaunchOptionsMapSpanKey : [NSValue valueWithMKCoordinateSpan:regionSpan]

};

Page 88: Session 300 - Getting Around Using Map Kit

TrafficLaunch Options

NSDictionary *options = @{

};

Page 89: Session 300 - Getting Around Using Map Kit

TrafficLaunch Options

NSDictionary *options = @{

MKLaunchOptionsShowsTrafficKey :@YES,

};

Page 90: Session 300 - Getting Around Using Map Kit

Getting Directions

Page 91: Session 300 - Getting Around Using Map Kit

-openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions:

mosconeItem

Getting Directions

Page 92: Session 300 - Getting Around Using Map Kit

-openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions:

mosconeItem

Getting Directions

DirectionsModeKey

Page 93: Session 300 - Getting Around Using Map Kit

-openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions:

Current Location

mosconeItem

Getting Directions

DirectionsModeKey

Page 94: Session 300 - Getting Around Using Map Kit

-openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions: -openInMapsWithLaunchOptions:

Current Location

mosconeItem

Getting Directions

DirectionsModeKey

Page 95: Session 300 - Getting Around Using Map Kit

MKMapItem *mosconeItem = ...

NSDictionary *options = @{ MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving,};

[mosconeItem openInMapsWithLaunchOptions:options];

Getting DirectionsFrom your current location

Page 96: Session 300 - Getting Around Using Map Kit

mosconeItem

airportItem

Directions from a Custom Origin

DirectionsModeKey

Page 97: Session 300 - Getting Around Using Map Kit

NSArray

mosconeItem

airportItem

Directions from a Custom Origin

DirectionsModeKey

Page 98: Session 300 - Getting Around Using Map Kit

+openMapsWithItems:launchOptions:

NSArray

mosconeItem

airportItem

Directions from a Custom Origin

DirectionsModeKey

Page 99: Session 300 - Getting Around Using Map Kit

+openMapsWithItems:launchOptions:

mosconeItem

airportItem

Directions from a Custom Origin

DirectionsModeKey

Page 100: Session 300 - Getting Around Using Map Kit

+openMapsWithItems:launchOptions:

mosconeItem

airportItem

Directions from a Custom Origin

DirectionsModeKey

Page 101: Session 300 - Getting Around Using Map Kit

NSArray *directionsItems = @[airportItem,mosconeWestItem];

Directions from a Custom Origin

Page 102: Session 300 - Getting Around Using Map Kit

NSArray *directionsItems = @[airportItem,mosconeWestItem];

Directions from a Custom Origin

Page 103: Session 300 - Getting Around Using Map Kit

NSArray *directionsItems = @[airportItem,mosconeWestItem];

NSDictionary *options = @{ MKLaunchOptionsDirectionsModeKey :

MKLaunchOptionsDirectionsModeDriving,};

Directions from a Custom Origin

Page 104: Session 300 - Getting Around Using Map Kit

NSArray *directionsItems = @[airportItem,mosconeWestItem];

NSDictionary *options = @{ MKLaunchOptionsDirectionsModeKey :

MKLaunchOptionsDirectionsModeDriving,};

[MKMapItem openMapsWithItems:directionsItems launchOptions:options];

Directions from a Custom Origin

Page 105: Session 300 - Getting Around Using Map Kit

Representing Current Location

Page 106: Session 300 - Getting Around Using Map Kit

Representing Current Location

MKMapItem *item = [MKMapItem mapItemForCurrentLocation];

Page 107: Session 300 - Getting Around Using Map Kit

Representing Current Location

MKMapItem *item = [MKMapItem mapItemForCurrentLocation];

• Current location item will NOT have a placemark

Page 108: Session 300 - Getting Around Using Map Kit

Representing Current Location

MKMapItem *item = [MKMapItem mapItemForCurrentLocation];

• Current location item will NOT have a placemarkmapItem.isCurrentLocation == YES

Page 109: Session 300 - Getting Around Using Map Kit

NSArray *directionsItems = @[mosconeWestItem,[MKMapItem mapItemForCurrentLocation]];

NSDictionary *options = @{ MKLaunchOptionsDirectionsModeKey :

MKLaunchOptionsDirectionsModeDriving,};

[MKMapItem openMapsWithItems:directionsItems launchOptions:options];

Directions from a Custom Origin

Page 110: Session 300 - Getting Around Using Map Kit

Launching Maps with MKMapItem

Page 111: Session 300 - Getting Around Using Map Kit

• Open Maps with minimal code

Launching Maps with MKMapItem

Page 112: Session 300 - Getting Around Using Map Kit

• Open Maps with minimal code• Offer quick access to navigation, bookmarks, and more

Launching Maps with MKMapItem

Page 113: Session 300 - Getting Around Using Map Kit

• Open Maps with minimal code• Offer quick access to navigation, bookmarks, and more

• Keep your app focused

Launching Maps with MKMapItem

Page 114: Session 300 - Getting Around Using Map Kit

Integrated routing powered by the app storeDeveloping Routing Apps

Page 115: Session 300 - Getting Around Using Map Kit

Transportation modesThe Many Faces of Routing

Page 116: Session 300 - Getting Around Using Map Kit

Transportation modesThe Many Faces of Routing

Page 117: Session 300 - Getting Around Using Map Kit

Transportation modesThe Many Faces of Routing

Page 118: Session 300 - Getting Around Using Map Kit

Transportation modesThe Many Faces of Routing

Page 119: Session 300 - Getting Around Using Map Kit

+

Page 120: Session 300 - Getting Around Using Map Kit

+

Page 121: Session 300 - Getting Around Using Map Kit
Page 122: Session 300 - Getting Around Using Map Kit
Page 123: Session 300 - Getting Around Using Map Kit

There is a black mask behind me! Make sure I stay here so animations look nice.

Page 124: Session 300 - Getting Around Using Map Kit

There is a black mask behind me! Make sure I stay here so animations look nice.

Page 125: Session 300 - Getting Around Using Map Kit

There is a black mask behind me! Make sure I stay here so animations look nice.

Page 126: Session 300 - Getting Around Using Map Kit

There is a black mask behind me! Make sure I stay here so animations look nice.

Page 127: Session 300 - Getting Around Using Map Kit

There is a black mask behind me! Make sure I stay here so animations look nice.

Red Circle instead of text

Page 128: Session 300 - Getting Around Using Map Kit

There is a black mask behind me! Make sure I stay here so animations look nice.

Red Circle instead of text

Page 129: Session 300 - Getting Around Using Map Kit

There is a black mask behind me! Make sure I stay here so animations look nice.

Page 130: Session 300 - Getting Around Using Map Kit

There is a black mask behind me! Make sure I stay here so animations look nice.

Page 131: Session 300 - Getting Around Using Map Kit

Add graphic to show these are relevant apps based on the origin and destination.

Page 132: Session 300 - Getting Around Using Map Kit

Add graphic to show these are relevant apps based on the origin and destination.

Installed Routing AppsRecommended apps for your start and endpoint.

Page 133: Session 300 - Getting Around Using Map Kit

Add graphic to show these are relevant apps based on the origin and destination.

App Store SuggestionsPurchase from inside of Maps.

Page 134: Session 300 - Getting Around Using Map Kit

There is a black mask behind me! Make sure I stay here so animations look nice.

Red circle

Page 135: Session 300 - Getting Around Using Map Kit

There is a black mask behind me! Make sure I stay here so animations look nice.

Add a slide to make it more clear that we are getting directions from Moscone to Apple, Inc.

Page 136: Session 300 - Getting Around Using Map Kit

There is a black mask behind me! Make sure I stay here so animations look nice.

Add a slide to make it more clear that we are getting directions from Moscone to Apple, Inc.

Page 137: Session 300 - Getting Around Using Map Kit

Routing App Requirements

Page 138: Session 300 - Getting Around Using Map Kit

Routing App Requirements

1. Declare your app as a routing app

Page 139: Session 300 - Getting Around Using Map Kit

Routing App Requirements

1. Declare your app as a routing app2. Specify where your app is relevant geographically

Page 140: Session 300 - Getting Around Using Map Kit

Routing App Requirements

1. Declare your app as a routing app2. Specify where your app is relevant geographically3. Handle launches from Maps

Page 141: Session 300 - Getting Around Using Map Kit

Declare Your App as a Routing App

Page 142: Session 300 - Getting Around Using Map Kit

Declare Your App as a Routing App

Page 143: Session 300 - Getting Around Using Map Kit

Specifying Geographic CoverageWhere can your app provide routes?

Page 144: Session 300 - Getting Around Using Map Kit

Specifying Geographic CoverageWhere can your app provide routes?

Page 145: Session 300 - Getting Around Using Map Kit

Specifying Geographic CoverageWhere can your app provide routes?

Page 146: Session 300 - Getting Around Using Map Kit

Specifying Geographic CoverageWhere can your app provide routes?

Page 147: Session 300 - Getting Around Using Map Kit

Specifying Geographic CoverageWhere can your app provide routes?

Page 148: Session 300 - Getting Around Using Map Kit

Specifying Geographic CoverageWhere can your app provide routes?

Page 149: Session 300 - Getting Around Using Map Kit

Specifying Geographic CoverageWhere can your app provide routes?

Page 150: Session 300 - Getting Around Using Map Kit

Specifying Geographic CoverageWhere can your app provide routes?

Page 151: Session 300 - Getting Around Using Map Kit

Specifying Geographic CoverageRequirements

Page 152: Session 300 - Getting Around Using Map Kit

• GeoJSON file format (.geojson)

Specifying Geographic CoverageRequirements

Page 153: Session 300 - Getting Around Using Map Kit

• GeoJSON file format (.geojson)• Provide one MultiPolygon

Specifying Geographic CoverageRequirements

Page 154: Session 300 - Getting Around Using Map Kit

• GeoJSON file format (.geojson)• Provide one MultiPolygon• Keep it simple

Specifying Geographic CoverageRequirements

Page 155: Session 300 - Getting Around Using Map Kit

• GeoJSON file format (.geojson)• Provide one MultiPolygon• Keep it simple

■ Up to 20 polygons, 20 points per polygon

Specifying Geographic CoverageRequirements

Page 156: Session 300 - Getting Around Using Map Kit

• GeoJSON file format (.geojson)• Provide one MultiPolygon• Keep it simple

■ Up to 20 polygons, 20 points per polygon

• Coverage file is NOT part of the app bundle

Specifying Geographic CoverageRequirements

Page 157: Session 300 - Getting Around Using Map Kit

• GeoJSON file format (.geojson)• Provide one MultiPolygon• Keep it simple

■ Up to 20 polygons, 20 points per polygon

• Coverage file is NOT part of the app bundle■ Uploaded using iTunes Connect

Specifying Geographic CoverageRequirements

Page 158: Session 300 - Getting Around Using Map Kit

• GeoJSON file format (.geojson)• Provide one MultiPolygon• Keep it simple

■ Up to 20 polygons, 20 points per polygon

• Coverage file is NOT part of the app bundle■ Uploaded using iTunes Connect■ Automatically updated

Specifying Geographic CoverageRequirements

Page 159: Session 300 - Getting Around Using Map Kit

Testing Your Routing App

Page 160: Session 300 - Getting Around Using Map Kit

Testing Your Routing App

• Maps is now in the simulator

Page 161: Session 300 - Getting Around Using Map Kit

Testing Your Routing App

• Maps is now in the simulator• Verify your app appears when relevant

Page 162: Session 300 - Getting Around Using Map Kit

Testing Your Routing App

• Maps is now in the simulator• Verify your app appears when relevant

• Check the logs

Page 163: Session 300 - Getting Around Using Map Kit

Testing Your Routing App

• Maps is now in the simulator• Verify your app appears when relevant

• Check the logs■ Simulator—use Console

Page 164: Session 300 - Getting Around Using Map Kit

Testing Your Routing App

• Maps is now in the simulator• Verify your app appears when relevant

• Check the logs■ Simulator—use Console■ Device—use Xcode Organizer

Page 165: Session 300 - Getting Around Using Map Kit

DemoDeclaring your app as a routing app

Page 166: Session 300 - Getting Around Using Map Kit

Routing App Requirements

1. Declare your app as a routing app2. Specify where your app is relevant geographically3. Handle launches from Maps

Page 167: Session 300 - Getting Around Using Map Kit

Handling Launches from Maps

MKMapItem

MKMapItem

Page 168: Session 300 - Getting Around Using Map Kit

Handling Launches from Maps

MKMapItem

Current Location

Page 169: Session 300 - Getting Around Using Map Kit

Handling Launches from Maps

MKDirectionsRequest

MKMapItem

Current Location

Page 170: Session 300 - Getting Around Using Map Kit

Handling Launches from Maps

MKDirectionsRequest

MKMapItem

Current Location

NSURL

Page 171: Session 300 - Getting Around Using Map Kit

Handling Launches from Maps

NSURL

Page 172: Session 300 - Getting Around Using Map Kit

NSURL

Handling Launches from Maps

Page 173: Session 300 - Getting Around Using Map Kit

MKDirectionsRequest

NSURL

Handling Launches from Maps

• Is it a MKDirectionsRequest URL?

Page 174: Session 300 - Getting Around Using Map Kit

MKDirectionsRequest

NSURL

Handling Launches from Maps

• Is it a MKDirectionsRequest URL?• If yes, instantiate the request using the URL

Page 175: Session 300 - Getting Around Using Map Kit

MKDirectionsRequest

Current Location

NSURL

Handling Launches from Maps

• Is it a MKDirectionsRequest URL?• If yes, instantiate the request using the URL@property MKMapItem *source;

Page 176: Session 300 - Getting Around Using Map Kit

MKDirectionsRequest

MKMapItem

Current Location

NSURL

Handling Launches from Maps

• Is it a MKDirectionsRequest URL?• If yes, instantiate the request using the URL@property MKMapItem *source;@property MKMapItem *destination;

Page 177: Session 300 - Getting Around Using Map Kit

MKDirectionsRequest

MKMapItem

Current Location

NSURL

Handling Launches from Maps

• Is it a MKDirectionsRequest URL?• If yes, instantiate the request using the URL@property MKMapItem *source;@property MKMapItem *destination;

• Resolve the current location map item

Page 178: Session 300 - Getting Around Using Map Kit

MKDirectionsRequest

MKMapItem

Current Location

NSURL

Handling Launches from Maps

• Is it a MKDirectionsRequest URL?• If yes, instantiate the request using the URL@property MKMapItem *source;@property MKMapItem *destination;

• Resolve the current location map item• Provide your route!

Page 179: Session 300 - Getting Around Using Map Kit

Handling Launches from Maps

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{

}

Page 180: Session 300 - Getting Around Using Map Kit

Handling Launches from Maps

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{ if ([MKDirectionsRequest isDirectionsRequestURL:url]) {

}}

Page 181: Session 300 - Getting Around Using Map Kit

Handling Launches from Maps

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{ if ([MKDirectionsRequest isDirectionsRequestURL:url]) { MKDirectionsRequest *request = [[MKDirectionsRequest alloc]

initWithContentsOfURL:url];

MKMapItem *startItem = [request source]; MKMapItem *endItem = [request destination];

// YOUR CODE HERE}

}

Page 182: Session 300 - Getting Around Using Map Kit

DemoUsing the MKDirectionsRequest to provide a route

Page 183: Session 300 - Getting Around Using Map Kit

Best practicesMaking Great Routing Apps

Page 184: Session 300 - Getting Around Using Map Kit

Best practicesMaking Great Routing Apps

• Minimize user input after launch

Page 185: Session 300 - Getting Around Using Map Kit

Best practicesMaking Great Routing Apps

• Minimize user input after launch• Personalize display using MKMapItem data

Page 186: Session 300 - Getting Around Using Map Kit

Best practicesMaking Great Routing Apps

• Minimize user input after launch• Personalize display using MKMapItem data• Be reasonable with geographic coverage

Page 187: Session 300 - Getting Around Using Map Kit

Routing Apps

Page 188: Session 300 - Getting Around Using Map Kit

Routing Apps

• Integrate with Maps

Page 189: Session 300 - Getting Around Using Map Kit

Routing Apps

• Integrate with Maps• Increase traffic to your app

Page 190: Session 300 - Getting Around Using Map Kit

Routing Apps

• Integrate with Maps• Increase traffic to your app• Get promoted to users who care

Page 191: Session 300 - Getting Around Using Map Kit

Summary

Page 192: Session 300 - Getting Around Using Map Kit

Summary

New Maps. Same API.

Page 193: Session 300 - Getting Around Using Map Kit

Summary

New Maps. Same API. Open Maps with MKMapItem

Page 194: Session 300 - Getting Around Using Map Kit

Summary

New Maps. Same API. Open Maps with MKMapItem

Routing Apps

Page 195: Session 300 - Getting Around Using Map Kit

More Information

Paul MarcosApplication Services [email protected]

DocumentationMKMapViewhttp://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapView_Class/

Location Awareness Programming Guidehttp://developer.apple.com/library/ios/#DOCUMENTATION/UserExperience/Conceptual/LocationAwarenessPG/

WWDC 2011“Visualizing Information Geographically with MapKit”

Apple Developer Forumshttp://devforums.apple.com

Page 196: Session 300 - Getting Around Using Map Kit

Related Sessions

Getting Around with Map Kit (Repeat) Pacific HeightsTuesday 3:15PM

Staying on Track with Location Services Nob HillWednesday 2:00PM

What’s new in iTunes Connect for App Developers Nob HillThursday 9:00AM

Page 197: Session 300 - Getting Around Using Map Kit

Labs

MapKit Lab #1 App Services Lab BTuesday 4:30PM

MapKit Lab #2 App Services Lab BThursday 11:30AM

Page 198: Session 300 - Getting Around Using Map Kit