There are two points
let locationA = CLLocationCoordinate2DMake(62.028850, 119.734073) let locationB = CLLocationCoordinate2DMake(42.028850, 88.734073) How to know the distance between them in meters (maybe there are some special features)?
There are two points
let locationA = CLLocationCoordinate2DMake(62.028850, 119.734073) let locationB = CLLocationCoordinate2DMake(42.028850, 88.734073) How to know the distance between them in meters (maybe there are some special features)?
extension CLLocationCoordinate2D { func distanceTo(coordinate: CLLocationCoordinate2D) -> CLLocationDistance { let thisLocation = CLLocation(latitude: self.latitude, longitude: self.longitude) let otherLocation = CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude) return thisLocation.distanceFromLocation(otherLocation) } } Make this extension for CLLocationCoordinate2D
Use in this way:
locationA.distanceTo(locationB) Return the distance in meters
Source: https://ru.stackoverflow.com/questions/580382/
All Articles