corelocation in practice - o'reilly mediaassets.en.oreilly.com/1/event/41/location sensors...

12
Alok Deshpande| 12.03.2009 CoreLocation in Practice

Upload: others

Post on 22-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID

Alok Deshpande| 12.03.2009

CoreLocation in Practice

Page 2: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID

CoreLocation Overview

Core Location

GPS Cell-ID Wi-Fi Compass

Page 3: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID

API Overview

CLLocationManager

CLLocation

CLLocationManagerDelegate

CLLocation CLLocation

Distance Filter

Coordinate (latitude, longitude) Accuracy Information Altitude, Timestamp…

Page 4: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID

Location Use Cases

•  What accuracy do you need? •  How frequently do you need to be

notified of location changes?

Accuracy Options

kCLLocationAccuracyBest kCLLocationAccuracyNearestTenMeters kCLLocationAccuracyHundredMeters

kCLLocationAccuracyKilometer kCLLocationAccuracyThreeKilometers;

Page 5: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID

Example App: where’s my car

•  Show a user’s location on a map

• Need high accuracy, continuously updating location

• Display distance to car

Page 6: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID

Start simple with MapKit

MapKit supports showing a user’s location

myMapView = [MKMapView alloc] init..]myMapView.showsUserLocation = YES

Page 7: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID
Page 8: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID

Subscribing to location

Page 9: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID

Handling Updates

When retrieving a single location fix

•  Updates are sent when a higher accuracy fix is available or the user has moved more than the distance filter amount

•  You may never get an update of a specific accuracy (ie: sub 100 meter accuracy)

Page 10: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID

Errors

Page 11: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID

Final Tips

•  Place a time limit on how long the search for a single fix can take

•  The simulator always places you in Cupertino, for real location use the device

•  Try testing your application with cold location hardware – restart your iPhone before running your application

Page 12: CoreLocation in Practice - O'Reilly Mediaassets.en.oreilly.com/1/event/41/Location Sensors Presentation.pdf · CoreLocation in Practice . CoreLocation Overview Core Location GPS Cell-ID

Questions?