假设我有两点:
var lat1 = 37.7833
var lon1 = -122.4167
var lat2 = 39.4811
var lon2 = -118.9558
如何最简单地计算它们之间的距离? (考虑到地球的曲率)
我调查了 this答案,但是 CCLocation
在 Swift 2.0 中没有初始化器
最佳答案
let coord1 = CLLocation(latitude: 37.7833, longitude: -122.4167)
let coord2 = CLLocation(latitude: 39.4811, longitude: -118.9558)
let distance = coord1.distance(from: coord2)
print("the distance between the two points is: \(distance) meters")
关于ios - 给定两组坐标,如何计算它们之间的距离?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35123785/