MapKit
     Julio Barros
Julio@E-String.com
Why Maps?

• iPhone is a mobile / pocket computer
• Where am I?
• What’s near me?
• How do I get somewhere?
Dark ages (pre 3.0)
• Static map images
• Web view with Javascript shenanigans
• Exit out to google maps
MapKit
• New in iPhone 3.x
• Embed map in your app
• Uses Google map tiles
• Familiar map UI
Important Classes
MKMapView


MKAnnotation (protocol)


MKAnnotationView
Important Classes
MKMapView
   MKMapViewDelegate
MKAnnotation (protocol)


MKAnnotationView
   MKPinAnnotationView
Simplest Example
• MKMapView ... just a view



• Don’t forget to add mapkit framework
• Or use Interface Builder
That was
  easy
Show User
 Location
Showing a
particular area on
     the map
               Latitude Span
     Center



“best fit” not exactly
    what you set
                               Longitude Span
Regions
• MKCoordinateRegion
Denver,
Colorado
Demo data
plist of Brewery information: name, address,
latitude, longitude
Loading Demo Data
Local area
MKAnnotation
MyAnnotation Class
Adding Annotations
Default Pins at
 annotations
Customizing pins
• MKPinAnnotationView
• MKMapViewDelegate - set a delegate
Our purple
  pins
Custom markers
• MKAnnotationView
Customizing
 the view
Customizing the
    Callout
Tapping the call out
       view
Reverse Geocoding

• Geocoding : address to coordinates
 • geocoder.us other services
• Reverse geocoding : coordinates to address
MKReverseGeocoder
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
Number of pins
• Try to limit
  annotations to ~100(?)
• Implement region
  change delegate
  methods
• Create and manage
  your own clusters
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
Legal limitations
I’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
Possible Options

• OpenStreetMap.org (OSM) - map/tile data
• Route-Me - OSS map view
• Cloudemade.com - services around OSM
• geocoder.us (among others)
Resources

• MapKit Framework Reference - Apple
• Using Map Kit with Bill Dudney - PragProg
• Using Map Kit ... Bill Dudney - Wednesday
Thank You
Julio Barros
Julio@E-String.com
http://www.E-String.com
http://twitter.com/JulioBarros
Also on Face book and Linked In

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