iPhone geo hacking 101
        Michael Dales
• where am I?
• no, really, I’m a human. where am I?
• Can you show me where I am?
• Can you show me where it is?
• where ...
CoreLocation
• where am I?
• no, really, I’m a human. where am I?
• Can you show me where I am?
• Can you show me where it...
CoreLocation
• where am I?
• no, really, I’m a human. where am I?
• Can you show me where I am?
• Can you show me where it...
CoreLocation
• where am I?
• no, really, I’m a human. where am I?
• Can you show me where I am?
• Can you show me where it...
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy =
   ...
- (void)locationManager: (CLLocationManager *)manager

 didUpdateToLocation: (CLLocation *)newLocation

 
      fromLocati...
CLLocation
•   Location info

    •   lat, long, accuracy

•   Altitude info, speed info,
    heading info

•   ask distan...
• Remember the user!
 • Battery matters to them
• Also available on the Mac
MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:
 coordinate];
geocoder.delegate = self;
[geoc...
MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:
     coordinate];
    geocoder.delegate = sel...
MKPlacemark
NSString   *thoroughfare; // street address, eg 1 Infinite Loop
NSString   *subThoroughfare;
NSString   *local...
maps demo
set where to look
 
   MKCoordinateRegion region;
 
   region.center = lastPoint.coordinate;
 
   region.span.latitudeDelt...
annotations
@interface LocationDemoAnnotation : NSObject <MKAnnotation,
MKReverseGeocoderDelegate>
{

 // essential

 CLLo...
making it personal
ABAddressBook *addressBook = [ABAddressBook addressBook];
ABPerson *me = [addressBook me];
id home = [m...
making it personal
ABAddressBook *addressBook = [ABAddressBook addressBook];
ABPerson *me = [addressBook me];
id home = [m...
what’s left

• Talking to something else
 • ASIHTTPRequest
 • JSON Framework
WhereCamp EU talk: iPhone location 101
WhereCamp EU talk: iPhone location 101
WhereCamp EU talk: iPhone location 101
WhereCamp EU talk: iPhone location 101
Upcoming SlideShare
Loading in...5
×

WhereCamp EU talk: iPhone location 101

1,816

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,816
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide






















  • WhereCamp EU talk: iPhone location 101

    1. 1. iPhone geo hacking 101 Michael Dales
    2. 2. • where am I? • no, really, I’m a human. where am I? • Can you show me where I am? • Can you show me where it is? • where should I be?
    3. 3. CoreLocation • where am I? • no, really, I’m a human. where am I? • Can you show me where I am? • Can you show me where it is? • where should I be?
    4. 4. CoreLocation • where am I? • no, really, I’m a human. where am I? • Can you show me where I am? • Can you show me where it is? MapKit • where should I be?
    5. 5. CoreLocation • where am I? • no, really, I’m a human. where am I? • Can you show me where I am? • Can you show me where it is? MapKit • where should I be? AddressBook
    6. 6. locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation];
    7. 7. - (void)locationManager: (CLLocationManager *)manager didUpdateToLocation: (CLLocation *)newLocation fromLocation: (CLLocation *)oldLocation { NSString *latitudeString = [[NSString alloc] initWithFormat: @"%g", newLocation.coordinate.latitude]; latitudeLabel.text = latitudeString; [latitudeString release]; NSString *longitudeString = [[NSString alloc] initWithFormat: @"%g", newLocation.coordinate.longitude]; longitudeLabel.text = longitudeString; [longitudeString release]; }
    8. 8. CLLocation • Location info • lat, long, accuracy • Altitude info, speed info, heading info • ask distance from another point
    9. 9. • Remember the user! • Battery matters to them • Also available on the Mac
    10. 10. MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate: coordinate]; geocoder.delegate = self; [geocoder start];
    11. 11. MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate: coordinate]; geocoder.delegate = self; [geocoder start]; and a little later... - (void)reverseGeocoder: (MKReverseGeocoder *)geocoder didFindPlacemark: (MKPlacemark *)pplacemark { self.placemark = pplacemark; geocoder.delegate = nil; [geocoder autorelease]; }
    12. 12. MKPlacemark NSString *thoroughfare; // street address, eg 1 Infinite Loop NSString *subThoroughfare; NSString *locality; // city, eg. Cupertino NSString *subLocality; // neighborhood, landmark, common name, etc NSString *administrativeArea; // state, eg. CA NSString *subAdministrativeArea; // county, eg. Santa Clara NSString *postalCode; // zip code, eg 95014 NSString *country; // eg. United States NSString *countryCode; // eg. US
    13. 13. maps demo
    14. 14. set where to look MKCoordinateRegion region; region.center = lastPoint.coordinate; region.span.latitudeDelta = 0.002; region.span.longitudeDelta = 0.002; [mapView setRegion: region animated: YES];
    15. 15. annotations @interface LocationDemoAnnotation : NSObject <MKAnnotation, MKReverseGeocoderDelegate> { // essential CLLocationCoordinate2D coordinate; } @property (nonatomic, readonly) CLLocationCoordinate2D coordinate; - (id)initWithCoordinate: (CLLocationCoordinate2D)coord; - (NSString *)title; - (NSString *)subtitle;
    16. 16. making it personal ABAddressBook *addressBook = [ABAddressBook addressBook]; ABPerson *me = [addressBook me]; id home = [me valueForProperty: kABAddressProperty];
    17. 17. making it personal ABAddressBook *addressBook = [ABAddressBook addressBook]; ABPerson *me = [addressBook me]; id home = [me valueForProperty: kABAddressProperty]; 2010-03-12 13:34:09.804 MacLocationTest[34432:a0b] ABPerson (0x20009d180) { ABPersonFlags : 0 Address :{ home { City = Impington; Country = UK; State = Cambridge; Street = "42 North Road"; ZIP = "CB99 9ZX"; } } Creation : 2010-01-04 18:00:01 +0000 First : Michael Last : Dales Modification : 2010-03-12 13:29:27 +0000 Unique ID : 506661FE-8D0D-407F-AEAB-61699D59E943:ABPerson }
    18. 18. what’s left • Talking to something else • ASIHTTPRequest • JSON Framework
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×