I know from documentation we can find distance between two CLLocation
points using the function, distanceFromLocation:
. But my problem is I dont ha
Swift 5:
extension CLLocation {
/// Get distance between two points
///
/// - Parameters:
/// - from: first point
/// - to: second point
/// - Returns: the distance in meters
class func distance(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) -> CLLocationDistance {
let from = CLLocation(latitude: from.latitude, longitude: from.longitude)
let to = CLLocation(latitude: to.latitude, longitude: to.longitude)
return from.distance(from: to)
}
}