Calculate distance between 2 point on maps for iOS

Fiorelo Odobashi picture Fiorelo Odobashi · Aug 6, 2017 · Viewed 13k times · Source

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?

Answer

Hussain Shabbir picture Hussain Shabbir · Aug 6, 2017

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)