How to find out distance between coordinates?

前端 未结 10 1272
猫巷女王i
猫巷女王i 2020-12-12 15:23

I want to make it so that it will show the amount of distance between two CLLocation coordinates. Is there someway to do this without a complex math formula? If there isn\'t

10条回答
  •  感情败类
    2020-12-12 16:20

    For swift 4

       let locationOne = CLLocation(latitude: lat, longitude: long)
       let locationTwo = CLLocation(latitude: lat,longitude: long)
    
      let distance = locationOne.distance(from: locationTwo) * 0.000621371
    
      distanceLabel.text = "\(Int(round(distance))) mi"
    

提交回复
热议问题