Questions tagged [cllocationdistance]

Part of the Core Location Data Types. This is a distance measurement (in meters) from an existing location.

77 questions
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
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…
20
votes
8 answers

How to track user location in background?

I'm looking for an open source app or library to track user location in the background. Now I'm trying to do it with CLLocation and background tasks, but accuracy is not enough for my case. Could you explain, how apps, like "moves", "runkeeper",…
Alexey Sidorov
  • 846
  • 1
  • 9
  • 17
12
votes
3 answers

Find closest longitude and latitude in array from user location - iOS Swift

In the question posted here, the user asked: I have an array full of longitudes and latitudes. I have two double variables with my users location. I'd like to test the distance between my user's locations against my array to see which location is…
tsteve
  • 549
  • 1
  • 7
  • 16
10
votes
4 answers

iOS CoreLocation Altitude

Prior to iOS 4.0, CoreLocation was reporting altitude correctly, now it always reports as 0 ft. -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation *)oldLocation { NSString…
WrightsCS
  • 50,551
  • 22
  • 134
  • 186
7
votes
2 answers

CLLocation distanceFromLocation (in Swift?)

Can somebody please help me convert the following Objective-C statement to Swift? CLLocationDistance distance = [fromLocation distanceFromLocation:toLocation]; I know that it must be simple to do that. I am brand new to iOS programming and any help…
Proteus
  • 93
  • 1
  • 4
5
votes
4 answers

NSLengthFormatter get stringFromMeters: in miles/kilometers only

I am using the NSLengthFormatter class to format the distance between the user and some destination. CLLocation *userLocation; //<- Coordinates fetched from CLLocationManager CLLocation *targetLocation; //<- Some location retrieved from server…
ZeMoon
  • 20,054
  • 5
  • 57
  • 98
4
votes
3 answers

Calculating trip distance core location swift

I have an application where I calculate distance travelled like the Uber application. When a driver starts a trip, the location begins to change even though a start point has been specified in the search for a ride, a driver could decide to pass an…
King
  • 1,885
  • 3
  • 27
  • 84
3
votes
2 answers

Reverse function of MKCoordinateRegionMakeWithDistance?

MapKit's built in function MKCoordinateRegionMakeWithDistance takes distances in meters and turns them into a MKCoordinateRegion: func MKCoordinateRegionMakeWithDistance( _ centerCoordinate: CLLocationCoordinate2D, _ latitudinalMeters:…
3
votes
1 answer

Convert a String to CLLocationDistance

I cannot find any examples of how to convert a String to CLLocationDistance. For example: let distance : String = "2000.0" let mdf = MKDistanceFormatter() mdf.units = .Metric var clDistance = mdf.distanceFromString(distance) I always get…
Seck Ghost
  • 43
  • 2
3
votes
2 answers

Find nearest annotations from user location ios?

I have an array of annotations.I am calculating the distance between each annotation from user location.What I want to know is, how can I find lets say 3 nearest annotations from these distances? Here is how I am calculating distance from user…
iCodes
  • 1,382
  • 3
  • 21
  • 47
3
votes
2 answers

CLLocation accepts longitude and latitude greater or less than their min and max values

As far as I know, the max and min values are: latitude: [-90, 90] longitude: [-180, 180] CLLocation still accepts values beyond these limits, for example: [[CLLocation alloc] initWithLatitude:100.0 longitude:-200.0]; And the…
MiuMiu
  • 1,905
  • 2
  • 19
  • 28
2
votes
1 answer

Convert distanceFromLocation to Int

I'm sure there is an obvious solution to this issue, but I've been trying different things for a while now and I can't figure it out. Basically I have got the distance between two points, and I am trying to convert it from a Double to an Int (to…
user3746428
  • 11,047
  • 20
  • 81
  • 137
2
votes
3 answers

How to convert MKUserLocation to CLLocation? - swift

I need a way to convert MKUserLocation to CLLocation so that I can find the distance between the user location and another predefined CLLocation using the distanceFromLocation method in swift.
dhruvm
  • 2,672
  • 2
  • 19
  • 24
2
votes
2 answers

Find closest longitude and latitude in array from user location

I have an array full of longitudes and latitudes. I have two double variables with my users location. I'd like to test the distance between my user's locations against my array to see which location is the closest. How do I do this? This will get…
1
2 3 4 5 6