Transcript
Page 2: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Why Maps?

• iPhone is a mobile / pocket computer

• Where am I?

• What’s near me?

• How do I get somewhere?

Page 3: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Dark ages (pre 3.0)

• Static map images

• Web view with Javascript shenanigans

• Exit out to google maps

Page 4: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

MapKit

• New in iPhone 3.x

• Embed map in your app

• Uses Google map tiles

• Familiar map UI

Page 5: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Important Classes

MKMapView

MKAnnotation (protocol)

MKAnnotationView

Page 6: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Important Classes

MKMapView

MKMapViewDelegate

MKAnnotation (protocol)

MKAnnotationView

MKPinAnnotationView

Page 7: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Simplest Example

• MKMapView ... just a view

• Don’t forget to add mapkit framework

• Or use Interface Builder

Page 8: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

That was easy

Page 9: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Show User Location

Page 10: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Center

Latitude Span

Longitude Span

“best fit” not exactly what you set

Showing a particular area on

the map

Page 11: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

• MKCoordinateRegion

Regions

Page 12: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Denver, Colorado

Page 13: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Demo dataplist of Brewery information: name, address, latitude, longitude

Page 14: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Loading Demo Data

Page 15: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Local area

Page 16: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

MKAnnotation

Page 17: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

MyAnnotation Class

Page 18: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Adding Annotations

Page 19: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Default Pins at annotations

Page 20: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Customizing pins• MKPinAnnotationView

• MKMapViewDelegate - set a delegate

Page 21: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Our purple pins

Page 22: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Custom markers• MKAnnotationView

Page 23: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Customizing the view

Page 24: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Customizing the Callout

Page 25: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Tapping the call out view

Page 26: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Reverse Geocoding

• Geocoding : address to coordinates

• geocoder.us other services

• Reverse geocoding : coordinates to address

Page 27: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

MKReverseGeocoder

Page 28: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

MKPlacemark

• Address info including, country code, country, postal code, administrative area, sub administrative area, locality, sub locality, thoroughfare, sub thoroughfare

• Conforms to MKAnnotation

• Has address dictionary with Address Book keys

Page 29: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Number of pins• Try to limit

annotations to ~100(?)

• Implement region change delegate methods

• Create and manage your own clusters

Page 30: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Challenges• Anchoring an object to a location on the

map and having it scale.

• Shapes - neighborhoods

• Lines - routes / paths

• View space to Geo Space- (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(UIView *)view

- (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view

Page 31: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Legal limitationsI’m not a lawyer but think carefully before using this for:

vehicle/fleet tracking

routing

cacheing tiles

geocoding / mass reverse geocoding

Read the TOS

http://code.google.com/apis/maps/iphone/terms.html

Page 32: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Possible Options

• OpenStreetMap.org (OSM) - map/tile data

• Route-Me - OSS map view

• Cloudemade.com - services around OSM

• geocoder.us (among others)

Page 33: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Resources

• MapKit Framework Reference - Apple

• Using Map Kit with Bill Dudney - PragProg

• Using Map Kit ... Bill Dudney - Wednesday

Page 34: Getting Oriented with MapKit: Everything you need to get started with the new mapping framework

Thank You

Julio Barros

[email protected]

http://www.E-String.com

http://twitter.com/JulioBarros

Also on Face book and Linked In


Top Related