IOS and Location Services CS4521. Core Location Core Location Framework to determine the current latitude and longitude of a device Core Location uses.

Slides:



Advertisements
Similar presentations
View-Based Application Development Lecture 1 1. Flows of Lecture 1 Before Lab Introduction to the Game to be developed in this workshop Comparison between.
Advertisements

VIP Smartphone Team – Ahmad, Din, Vinayak Car Locator App Fall 2010 VIP Smartphone Team Ahmad, Din, Vinayak.
Touchdevelop api api: location & maps show geo locations Disclaimer: This document is provided “as-is”. Information and views expressed in this document,
The Web Warrior Guide to Web Design Technologies
HTML 5 – GeoLocation and Maps. Geolocation API What is a ”geolocation”…? A geographical location, defined in terms of – Latitude (north/south) – Longitude.
Introduction to Objective-C and Xcode (Part 1) FA 175 Intro to Mobile App Development.
Tracking & Login Data persistence User tracking.
Sensors. Point your phone at the sky, and Google Sky Map tells you which stars you’re looking at. Tilt your phone, and you can control the game you’re.
UIAlertView, UIActionSheet, and Facebook Connection Lecture 4 1.
Anatomy of an iPhone Application Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
View Controllers (second part) Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Multi-criteria infrastructure for location-based applications Shortly known as: Localization Platform Ronen Abraham Ido Cohen Yuval Efrati Tomer Sole'
SDReaderCE An Overview on Use and Functionality. Using SDReaderCE After loading the route to the handheld from SDReader6, select the route folder from.
Broadcast service Core tools. Agenda 1.Introduction – tool and its main features 2.Setting up and sending a simple broadcast 3.Achieving.
CS378 - Mobile Computing Location (Location, Location, Location)
CS378 - Mobile Computing Location.
Dataface API Essentials Steve Hannah Web Lite Solutions Corp.
Xcode Presentation Tom Pletzke. Creating App from template Launch Xcode Select Tabbed Application.
Location-Based API 1. 2 Location-Based Services or LBS allow software to obtain the phone's current location. This includes location obtained from the.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
REMINDER + RADAR Brad Bootz, Robert Douglas, Natalie Freed Team Members: Getting things done… one place at a time R.
Location based services
INTRODUCTION TO HTML5 Geolocation. Display a Specific Location with Google Maps  You can use the Google Maps API to display a custom map on your own.
Objective C Basics. It’s C with Some Extras!  Cross Platform language  Mac  Linux/UNIX  Windows  Layer above C (Superset)  Adds Object-Oriented.
Specview 32 Release 2.5 Enhancements
IOS with Swift Hello world app.
1 Chapter 12: Form Builder Objects and Flexible Code.
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Gestures UIGestureRecognizer.
 Facebook Integration on iOS Phan Thanh Phat Huynh Thanh Van.
GPS Provider:  GPS signal Network Location Provider:  Cell ID  Wi-Fi.
Location. GPS Global Positioning System – At least 4 satellites typically used 3 required extra for error detection and altitude typically accurate within.
Nav Controllers UINavigationController. Overview Nav Controller basics Like a tabview controller, a navViewController manages views A navigationViewController.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
WinCvs. WinCVS WinCvs is a window based version control system. Use WinCvs when  You want to save every version of your file you have ever created. CVS.
Designing Classes CS239 – Jan 26, Key points from yesterday’s lab  Enumerated types are abstract data types that define a set of values.  They.
Android - Location Based Services. Google Play services facilitates adding location awareness to your app with automated location tracking Geo fencing.
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
Phonegap Bridge – Device, Network, Console, Geolocation API’s CIS 136 Building Mobile Apps 1.
Twist, Touch & Travel Touch, Twist, and Travel Harnessing the iPhone's Unique Features Glenda Adams Maverick Software
1 UI Alert View iPhone/iPad, iOS Development Tutorial.
Lecture 10 Using Interface Builder to create Mac Applications.
The iOS Platform and SDK. iOS iPhoneiPad Mini iPad.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
DAY 14: ACCESS CHAPTER 1 RAHUL KAVI October 8,
Amolak Nagi.  “The Core Location framework lets you determine the current location or heading associated with a device.”
Phonegap Bridge –Geolocation and Google maps CIS 136 Building Mobile Apps 1.
WebViews UIWebView. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and xib) that manages.
1 디바이스 정보  UIDevice 클래스가 제공하고 static 메서드인 currentDevice 가 객체를 생성합 니다.  제공하는 정보 uniqueIdentifier: 장치 고유 ID / 회원가입을 하지 않고 어플을 운영 가능 model: 모델명 systemVersion:
1. 2 Android location services Determining a device’s current location Tracking device movements Proximity alerts.
SQL Database Management
Location And Maps Sisoft Technologies Pvt Ltd
Waypoint: An Off Road Navigator
Java FX: Scene Builder.
Tracking device movements
EE 200 Design Tools Laboratory 14
Delegates and Events 14: Delegates and Events
Brad Bootz, Robert Douglas, Natalie Freed
Geolocation using Google maps
Sensors, maps and fragments:
iOS LifeRhythm Data Collection
Using local variable without initialization is an error.
EEC-492/693/793 iPhone Application Development
iOS App Development Training
Geolocation using Google maps
Presented by Ignas Šeškauskas
Guidelines for Microsoft® Office 2013
CS378 - Mobile Computing Location and Maps.
EEC-492/693/793 iPhone Application Development
Geolocation using Google maps
Presentation transcript:

iOS and Location Services CS4521

Core Location Core Location Framework to determine the current latitude and longitude of a device Core Location uses a type of streaming notification so that your application receives updates as the GPS ascertains a more accurate fix. CAREFUL: can be expensive for battery

There are three technologies that core location uses : o GPS Reads microwave signals from multiple satellites to determine the current location o Cell Tower Triangulation Determine the current location by calculation based on location of cell towers in iPhone’s range. o Wi-Fi positioning Service (WPS) Uses IP address from iPhone’s Wi-Fi connection by referencing database of service providers and areas they service

Location Manager (CLLocationManager) create an instance of Location Manager. CLLocationManager *locationManager=[[CLLocationManager alloc]init]; Assign a delegate object to it, and configure the desired accuracy you want.

Location Object (CLLocation) Represents the location data generated by a CLLocationManager object. Lat, Long, accuracy and when taken

CLLocationAccuracy - Setting Desired Accuracy CONSTANTS declared in CoreLocation/CoreLocation.h (in degrading accuracy) CoreLocation o kCLLocationAccuracyBest o kCLLocationAccuracyNearestTenMeters o kCLLocationAccuracyHundredMetres o kCLLocationAccuracyKilometers o kCLLocationAccuracyThreeKilometers Setting Delegate and Accuracy: locationManager.delegate=self; locationManager.desiredAccuracy= kCLLocationAccuracyBest

Setting Distance Filter you can tell Location manager not to notify for every change in location but to only notify you when location changes by certain amount. Setting up a distance filter reduced the amount of polling that your application does. Specifying a distance filter of 1000 tells location manager not to notify the delegate until the iPhone has moved at least 1000 meters from previously reported position

For example: locationManager.distanceFilter=1000.0f; To return location manager to return to default setting with no filter then: locationManager.distanceFilter= kCLDistanceFilternone; Setting Distance Filter Example

Starting the Location Manager It will continue to call your delegate method whenever it senses a change that exceeds the current distance filter [locationManager startUpdatingLocation];

Location Manager Delegate CLLocationManagerDelegate defines the methods used to receive location and heading updates from a CLLocationManager object. CLLocationManager YOU WILL create your OWN Location Manager Delegate class and implement methods of your need.

CLLocationManagerDelegate Getting Location Updates When the location manager wants to inform its delegate of the current location, it calls: [LocationMangerDelegate locationManger:lm didUpdateToLocation:tLoc fromLocation:fLoc] locationManager:didUpdateToLocation:fromLoca tion o locationManager= First parameter is location Manager that called the delegate. o didUpdateToLocation= Second is CLLocation object that defines current location of iPhone o didUpdateToLocation= Third parameter is CLLocation object that defines previous location from last update (will be nil if method is called first time.)

Implement the method -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { //save location in class variable currentLocation self.currentLocation = newLocation; if(newLocation.horizontalAccuracy <= 100.0f) { [locationManager stopUpdatingLocation]; } }

Getting Latitude and Longitude using CLLocation CLLocation object has some properties that might be interest to your application The latitude and longitude are stored in property called coordinate. CLLocationDegrees latitude=theLocation.coordinate.latitude; CLLocationDegrees longitude=theLocation.coordinate.longitude; CLLocation object also tell you how confident the location manager is in latitude and longitude calculations by the property horizontalAccuracy which describes the radius a circle with coordinates as its center.

Getting Latitude and Longitude using CLLocation The CLLocation object also has a property called altitude that tell you how many metres above the sea level you are: CLLocationDistance altiude=theLocation.altitude Each CLLocation object maintains a property called verticalAccuracy that indicate how confident core location is in its altitude determination. If verticalAccuracy is negative core location is telling you that it cannot determine the altitude.

Getting Latitude and Longitude using CLLocation has timestamp getDistanceFrom: method calculates distance etween 2 CLLocation objects CLLocationDistance dist; dist =[fromLocation getDistanceFrom:toLocation]; Note: ignores the altitude as if both locations are at sea level

Error Notification locationManager:didFailWithError:. o Method called when can not get location of device will call second delegate method named KCLErrorDenied: o first time your application goes to determine location an alert will popup on screen asking user if its OK for the current program to access your location. o If user clicks the Don’t Allow button,your delegate will be notified with an error code kCLErrorDenied. kCLErrorLocationUnnown o which indicate core location unable to determine location but will keep trying.

Another CCLocationManagerDelegate method – handling errors -(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { if(error.code == kCLErrorDenied) { [locationManager stopUpdatingLocation]; } else if(error.code == kCLErrorLocationUnknown) { // retry } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle retrieving location" message:[error description] delegate:nil otherButtonTitles:nil]; [alert show]; } }

Trying Out Core Location >>>app get current location and total distance travelled while program has been running.

Step 1- create the project In Xcode, create a new project using view-based application template and call the project WhereAmI.. Expand the classes and resources folders and single-click WhereAmIViewContoller..h and make following changes

Step 2- WhereAmIViewContoller..h NOTE: your app’s ViewController IS the CLLocationMangerDelegate NOTE: ViewController contains class variables of the CLLocationManger and Current CLLocation

Step 2- Create XIB using Interface Builder 1.Open WhereAmIViewController.xib in IB. Drag 6 UILabel labels from library to the view window. 2.Connect to proper outlets

Step 3- WhereAmIViewController.m Create this code Get CLLocationManger and start it

Release locationManger --- save Battery!!!!

Step4: To WhereAmIViewController.h add the CLLocationManager Delegate Method to get Update Gets Lat and Long and saves it in UILabel’s of the View

Step5: To WhereAmIViewController.h add the CLLocationManager Delegate Method to handle Errors

Application