Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate distance between 2 point on maps for iOS [closed]

Is it possible to calculate the distance between 2 close points on iOS using Apple map framework or Google framework? For example, i want to get the distance between this 2 blu point with the highest accuracy possible.

enter image description here

Using google maps or apple maps can i get the 2 coordinate with a lot of digit? how can i calculate the distance in centimeters or millimeters?

like image 211
Fiorelo Odobashi Avatar asked Aug 06 '17 15:08

Fiorelo Odobashi


2 Answers

Try this -

let coordinate0 = CLLocation(latitude: 5.0, longitude: 5.0)
let coordinate1 = CLLocation(latitude: 5.0, longitude: 3.0)
let distanceInMeters = coordinate0.distance(from: coordinate1)
like image 183
Hussain Shabbir Avatar answered Sep 21 '22 07:09

Hussain Shabbir


Yes, you'll get accurate enough position information. CLLocation has a distance(from: CLLocation) function that does the trick and gives accurate results also for short distances.

like image 39
meaning-matters Avatar answered Sep 25 '22 07:09

meaning-matters