Questions tagged [cllocation]

A CLLocation object represents the location data generated by a CLLocationManager object. This object incorporates the geographical coordinates and altitude of the device’s location along with values indicating the accuracy of the measurements and when those measurements were made. In iOS, this class also reports information about the speed and heading in which the device is moving.

A CLLocation object represents the location data generated by a CLLocationManager object. This object incorporates the geographical coordinates and altitude of the device’s location along with values indicating the accuracy of the measurements and when those measurements were made. In iOS, this class also reports information about the speed and heading in which the device is moving.

Typically, you use a CLLocationManager object to create instances of this class based on the last known location of the user’s device. You can create instances yourself, however, if you want to cache custom location data or get the distance between two points.

This class is designed to be used as is and should not be subclassed.

https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html#//apple_ref/doc/uid/TP40007126

810 questions
86
votes
19 answers

didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

I want to get the current location, but instead I get an error. This is a snippet of my view controller. - (void)viewDidLoad { self.locationManager = [[CLLocationManager alloc] init]; [locationManager setDelegate:self]; [locationManager…
Luca
  • 20,399
  • 18
  • 49
  • 70
82
votes
10 answers

How to find out distance between coordinates?

I want to make it so that it will show the amount of distance between two CLLocation coordinates. Is there someway to do this without a complex math formula? If there isn't how would you do it with a formula?
John Doe
  • 1,609
  • 2
  • 13
  • 22
64
votes
4 answers

How to check that CLLocationCoordinate2D is not empty?

How to check that CLLocationCoordinate2D is not empty?
Shmidt
  • 16,436
  • 18
  • 88
  • 136
51
votes
13 answers

How can I compare CLLocationCoordinate2D

I need a way of comparing two CLLocationCoordinate2D's however when I tried using == it wouldn't work. Please can someone help me out with the best way of comparing them?
user843337
42
votes
1 answer

What do horizontalAccuracy and verticalAccuracy of a CLLocation refer to?

I've been working on a location based app recently and am noticing some strange values for CLLocation. I often get a horizontalAccuracy of 1414 and a verticalAccuracy of -1. Any clue what this indicates? As far as I can tell, these points are often…
Alex Argo
  • 8,920
  • 12
  • 43
  • 46
41
votes
13 answers

CLLocationManager on iPhone Simulator fails with kCLErrorDomain Code=0

CLLocationManager on iPhone Simulator is supposed to fake Cupertino (isn't it?) but it does NOT, it fails with kCLErrorDomain Code=0 instead. LocationManager's delegate receives the message didFailWithError. This method is implemented to log the…
albertamg
  • 28,492
  • 6
  • 64
  • 71
37
votes
8 answers

didUpdateLocations not called

I'm trying to get my current location, but the break point in didUpdateLocations is never being called. LocationManager: locationManager = [[CLLocationManager alloc] init]; [locationManager setDelegate:self]; [locationManager…
mikeholp
  • 965
  • 3
  • 11
  • 14
35
votes
8 answers

Zoom MKMapView to fit polyline points

I have an array, allCollections, that holds programmatically-created arrays of CLLocations the user has recorded through my iOS app. Each sub-array in allCollections holds all the location points in a trip taken. I draw MKPolylines off of the…
user768339
  • 603
  • 2
  • 7
  • 8
34
votes
5 answers

How to store CLLocation using Core Data (iPhone)?

I'm trying to save a location and retrieve the location on a map afterward using Core Location, MapKit and Core Data frameworks. What I've done is I just made entity named POI and added properties such as latitude (double type), longitude (double…
bicbac
  • 435
  • 1
  • 9
  • 20
34
votes
2 answers

Calculating bearing between two CLLocation points in Swift

I'm trying to calculate a bearing between two CLLocation points in swift-only code. I've run into some difficulty and was assuming this is a pretty simple function. Stack overflow didn't seem to have anything listed. func d2r(degrees : Double) ->…
Jeef
  • 26,861
  • 21
  • 78
  • 156
32
votes
3 answers

Decoding the CLLocationAccuracy const's

the following are listed in CLLocation.h but from my experience they are deceiving names- possibly originally thought up to serve two purposes, 1. to test the accuracy of the location returned, but also 2. to set how hard the location manager works,…
dave
  • 883
  • 3
  • 11
  • 13
31
votes
8 answers

CLLocation Category for Calculating Bearing w/ Haversine function

I'm trying to write a category for CLLocation to return the bearing to another CLLocation. I believe I'm doing something wrong with the formula (calculous is not my strong suit). The returned bearing is always off. I've been looking at this question…
Nick
  • 8,483
  • 10
  • 46
  • 65
31
votes
12 answers

How to stop multiple times method calling of didUpdateLocations() in ios

This my code...... -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { location_updated = [locations lastObject]; NSLog(@"updated coordinate are %@",location_updated); latitude1 =…
user3378632
27
votes
2 answers

CLLocationManager and accuracy issues - any experiences?

So I am dealing with some accuracy issues with iPhone GPS. I have an app which uses location. In the delegate method locationManager: didUpdateToLocation: fromLocation: I am being returned a location. From a bit of research, it appears the GPS isn't…
runmad
  • 14,846
  • 9
  • 99
  • 140
24
votes
2 answers

Initialize a CLLocation object in swift with latitude and longitude

In objective C (I have no experience with it) you can initialize a CLLocation object with latitude and longitude likes this: CLLocation *myLocation = [[CLLocation alloc] initWithLatitude:your_latitiude_value longitude:your_longitude_value]; But…
1
2 3
53 54