![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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/1.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/2.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/3.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/4.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/5.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/6.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/7.jpg)
![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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/8.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/9.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/10.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/11.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022050220/5f657e6b2dd833002a527598/html5/thumbnails/12.jpg)
Questions?