0

How to get user current location. I wants to track the speed of user and wants to draw the path when ever he move one to another place.

1 Answers1

0

You can get user current location by CLLocationManager:

Add the following code win ViewDidLoad:

CLLocationManager  *objLocationManager = [[CLLocationManager alloc] init];
objLocationManager.delegate = self;
objLocationManager.desiredAccuracy = kCLLocationAccuracyBest;
[objLocationManager requestWhenInUseAuthorization];
[objLocationManager startUpdatingLocation];

Here is the delegate that returns the latitude and longitude:

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
      CLLocation *currentLocation = locations; 
}
User511
  • 1,456
  • 10
  • 28
  • Actually it'll also return coordinates while we shaking iPhone. So we need the current coordinates only when we move not while we shaking the iPhone. – Anil Matrid Nov 22 '16 at 07:17
  • @AnilMatrid Shaking a phone also means that it is changing its location so it will definitely return the location even when you are shaking. – User511 Nov 22 '16 at 07:25
  • Yes you are right. But is there any way to get location only when we move, not when we shaking. Actually I wants to draw the path. So when I am shaking my iphone it'll draw the path without my movement. Thanks for your response. – Anil Matrid Nov 22 '16 at 08:23
  • You can set a range for drawing a path.If it is changing at some particular limit. You can draw a path. – User511 Nov 22 '16 at 09:36