SlideShare a Scribd company logo
1 of 23
Download to read offline
Working with the
iOS Core Location Framework
and Google Maps SDK
Lecture 10
Jonathan R. Engelsma
TOPICS
• The Fundamentals.
• Working with CoreLocation
• Working with Google Maps SDK
THE CURRENT LOCATION
• The ability to obtain the device’s
current location is a very powerful
feature!
• Enabler for context aware
computing
• App integrates content and
behavior relevant to current
location
OBTAININGTHE LOCATION
• Smartphones use a variety of
techniques to locate the device:
• GPS
• Assisted GPS
• Cellular / WiFiTriangulation
GLOBAL POSITIONING
SYSTEM
• Space-based satellite system (US Government)
• Requires line of sight to 4+ satellites
• Accuracy: ~ 3 - 15 meters.
• Can take time to get first fix.
• Don’t work well indoors.
ASSISTED GPS
• Greatly reduces theTTFF (time to first fix).
• Uses terrestrial radio network to accelerate connection to
satellite.
• Widely used by modern cell phones.
WIFI / CELLULAR
TRIANGULATION
• Uses terrestrial cellular
towers and wifi access
points to determine device
location.
• Can be used indoors!
OBTAININGTHE LOCATION
• Implication: Location data varies in accuracy.
Accurate Less Accurate
TAKES ENERGY!
• Getting a GEO fix takes a
lot of battery!
• device can’t sleep when
GPS receiver is running.
• make sure your apps
don’t misuse or you will
get uninstalled real fast!
CORE LOCATION
• CoreLocation Framework
• Provides apps with location coordinate and heading info.
• Can define geographical regions and monitor when user
crosses region boundaries.
• Also supports “beacon” regions with iBeacon devices.
LOCATION MANAGER
• CLLocationManager:
var locationManager = CLLocationManager()
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = 10.0
Determine how far the device must travel
before a new location update is generated.
LOCATION ACCURACY
Accuracy Technology
kCLLocationAccuracyBestForNavigation GPS
kCLLocationAccuracyBest GPS
kCLLocationAccuracyNearestTenMeters GPS
kCLLocationAccuracyHundredMeters
WiFi (GPS in rural
areas)
kCLLocationAccuracyKilometer Cell tower
kCLLocationAccuracyThreeKilometers Cell tower
LOCATION MANAGER
• CLLocationManager requires location updates asynchronously.
• View Controller typically implements the
CLLocationManagerDelegate protocol to receive these
updates.
LOCATION MANAGER
DELEGATE
func locationManager(manager: CLLocationManager!,
didChangeAuthorizationStatus status: CLAuthorizationStatus)
{
// called when authorization changes.
}
func locationManagerDidResumeLocationUpdates(manager: CLLocationManager!) {
// called when location updates start to arrive.
}
LOCATION MANAGER
DELEGATE
func locationManager(manager: CLLocationManager!,
didUpdateLocations locations: [AnyObject]!)
{
var location: CLLocation = locations.first as! CLLocation
// put code to handle location update here.
}
CLLOCATION
• CLLocation: represents the data generated by
CLLocationManager. It contains:
• geo coordinates and altitude
• accuracy indicator
• time
• speed and heading.
GEO CODING
• CLGeocoder: converts between a lat/long coordinate and a
user-friendly representation of that coordinate.
Lat: 42.963661
Long: -85.677515
Grand Rapids, MI
USA
reverse geo-coding
forward geo-coding
GEO-CODING GUIDELINES
• Geocoder requests involve the network and are rate limited:
• send one request per user action.
• cache the results if you do more than one action per loc.
• issue a new geocoding request only if user has moved a
significant distance.
• don’t use it in the background!
GOOGLE MAPS SDK
• Google Maps SDK is the alternative of
choice for Apple MapKit!
• Provides more detailed map tiles.
• Includes StreetView!
• Can optionally use Apple’s MapKit
framework
https://developers.google.com/maps/documentation/ios/intro
GOOGLE MAPS SDK
• Types: Normal, Satellite, Hybrid,Terrain
• Traffic Layer
• Indoor building maps where available. (Museum navigator!)
• Places API / Place Picker
• Panorama (StreetView)
• Interactive Markers
• Polygons
• Camera view animation
DISPLAY MODES
Standard Satellite StreetView
CREATING A MAPVIEW
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
var cameraAllendale = GMSCameraPosition.cameraWithLatitude(42.96356,
longitude: -85.8899, zoom: 14.7)
mapView = GMSMapView.mapWithFrame(CGRectZero, camera: cameraAllendale)
mapView.settings.compassButton = true
self.view = mapView
let marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(42.96356, -85.8899)
marker.title = "GVSU"
marker.snippet = "Allendale, MI"
marker.icon = UIImage(named: "gvsu")
marker.appearAnimation = kGMSMarkerAnimationPop
marker.map = mapView
}
READING ASSIGNMENT
• Chapter 21 in Programming iOS8 by Neuburg
• Google Map SDK Documentation / Example Code
• https://developers.google.com/maps/documentation/ios/

More Related Content

More from Jonathan Engelsma

Knowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better BeekeeperKnowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better BeekeeperJonathan Engelsma
 
BIP Hive Scale Program Overview
BIP Hive Scale Program OverviewBIP Hive Scale Program Overview
BIP Hive Scale Program OverviewJonathan Engelsma
 
Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc. Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc. Jonathan Engelsma
 
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline BeekeepersHarvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline BeekeepersJonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03) Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02) Jonathan Engelsma
 
So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper? So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper? Jonathan Engelsma
 
What Every IT Manager Should Know About Mobile Apps
What Every IT Manager Should Know About Mobile AppsWhat Every IT Manager Should Know About Mobile Apps
What Every IT Manager Should Know About Mobile AppsJonathan Engelsma
 
2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring ConferenceJonathan Engelsma
 
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...Jonathan Engelsma
 

More from Jonathan Engelsma (17)

Knowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better BeekeeperKnowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better Beekeeper
 
BIP Hive Scale Program Overview
BIP Hive Scale Program OverviewBIP Hive Scale Program Overview
BIP Hive Scale Program Overview
 
Selling Honey Online
Selling Honey OnlineSelling Honey Online
Selling Honey Online
 
Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc. Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc.
 
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline BeekeepersHarvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
 
So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper? So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper?
 
What Every IT Manager Should Know About Mobile Apps
What Every IT Manager Should Know About Mobile AppsWhat Every IT Manager Should Know About Mobile Apps
What Every IT Manager Should Know About Mobile Apps
 
Mobile Gamification
Mobile GamificationMobile Gamification
Mobile Gamification
 
2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference
 
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
 

Recently uploaded

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 

Recently uploaded (20)

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 

iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 10)

  • 1. Working with the iOS Core Location Framework and Google Maps SDK Lecture 10 Jonathan R. Engelsma
  • 2. TOPICS • The Fundamentals. • Working with CoreLocation • Working with Google Maps SDK
  • 3. THE CURRENT LOCATION • The ability to obtain the device’s current location is a very powerful feature! • Enabler for context aware computing • App integrates content and behavior relevant to current location
  • 4. OBTAININGTHE LOCATION • Smartphones use a variety of techniques to locate the device: • GPS • Assisted GPS • Cellular / WiFiTriangulation
  • 5. GLOBAL POSITIONING SYSTEM • Space-based satellite system (US Government) • Requires line of sight to 4+ satellites • Accuracy: ~ 3 - 15 meters. • Can take time to get first fix. • Don’t work well indoors.
  • 6. ASSISTED GPS • Greatly reduces theTTFF (time to first fix). • Uses terrestrial radio network to accelerate connection to satellite. • Widely used by modern cell phones.
  • 7. WIFI / CELLULAR TRIANGULATION • Uses terrestrial cellular towers and wifi access points to determine device location. • Can be used indoors!
  • 8. OBTAININGTHE LOCATION • Implication: Location data varies in accuracy. Accurate Less Accurate
  • 9. TAKES ENERGY! • Getting a GEO fix takes a lot of battery! • device can’t sleep when GPS receiver is running. • make sure your apps don’t misuse or you will get uninstalled real fast!
  • 10. CORE LOCATION • CoreLocation Framework • Provides apps with location coordinate and heading info. • Can define geographical regions and monitor when user crosses region boundaries. • Also supports “beacon” regions with iBeacon devices.
  • 11. LOCATION MANAGER • CLLocationManager: var locationManager = CLLocationManager() locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.distanceFilter = 10.0 Determine how far the device must travel before a new location update is generated.
  • 12. LOCATION ACCURACY Accuracy Technology kCLLocationAccuracyBestForNavigation GPS kCLLocationAccuracyBest GPS kCLLocationAccuracyNearestTenMeters GPS kCLLocationAccuracyHundredMeters WiFi (GPS in rural areas) kCLLocationAccuracyKilometer Cell tower kCLLocationAccuracyThreeKilometers Cell tower
  • 13. LOCATION MANAGER • CLLocationManager requires location updates asynchronously. • View Controller typically implements the CLLocationManagerDelegate protocol to receive these updates.
  • 14. LOCATION MANAGER DELEGATE func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) { // called when authorization changes. } func locationManagerDidResumeLocationUpdates(manager: CLLocationManager!) { // called when location updates start to arrive. }
  • 15. LOCATION MANAGER DELEGATE func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { var location: CLLocation = locations.first as! CLLocation // put code to handle location update here. }
  • 16. CLLOCATION • CLLocation: represents the data generated by CLLocationManager. It contains: • geo coordinates and altitude • accuracy indicator • time • speed and heading.
  • 17. GEO CODING • CLGeocoder: converts between a lat/long coordinate and a user-friendly representation of that coordinate. Lat: 42.963661 Long: -85.677515 Grand Rapids, MI USA reverse geo-coding forward geo-coding
  • 18. GEO-CODING GUIDELINES • Geocoder requests involve the network and are rate limited: • send one request per user action. • cache the results if you do more than one action per loc. • issue a new geocoding request only if user has moved a significant distance. • don’t use it in the background!
  • 19. GOOGLE MAPS SDK • Google Maps SDK is the alternative of choice for Apple MapKit! • Provides more detailed map tiles. • Includes StreetView! • Can optionally use Apple’s MapKit framework https://developers.google.com/maps/documentation/ios/intro
  • 20. GOOGLE MAPS SDK • Types: Normal, Satellite, Hybrid,Terrain • Traffic Layer • Indoor building maps where available. (Museum navigator!) • Places API / Place Picker • Panorama (StreetView) • Interactive Markers • Polygons • Camera view animation
  • 22. CREATING A MAPVIEW override func viewDidLoad() { super.viewDidLoad() locationManager.delegate = self locationManager.requestWhenInUseAuthorization() var cameraAllendale = GMSCameraPosition.cameraWithLatitude(42.96356, longitude: -85.8899, zoom: 14.7) mapView = GMSMapView.mapWithFrame(CGRectZero, camera: cameraAllendale) mapView.settings.compassButton = true self.view = mapView let marker = GMSMarker() marker.position = CLLocationCoordinate2DMake(42.96356, -85.8899) marker.title = "GVSU" marker.snippet = "Allendale, MI" marker.icon = UIImage(named: "gvsu") marker.appearAnimation = kGMSMarkerAnimationPop marker.map = mapView }
  • 23. READING ASSIGNMENT • Chapter 21 in Programming iOS8 by Neuburg • Google Map SDK Documentation / Example Code • https://developers.google.com/maps/documentation/ios/