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

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

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/