Calculating Distance between two coordinates using CLLocation

后端 未结 4 1478
南方客
南方客 2021-01-13 12:03

I\'m using CLLocationDistance to get the distance between two points, but I\'m getting an error when passing my current location in it.

CLLocati         


        
4条回答
  •  天命终不由人
    2021-01-13 12:28

    To find distance in KM from two different Lat & Long

    let userLocation:CLLocation = CLLocation(latitude: 23.0320, longitude: 72.5250)
    let priceLocation:CLLocation = CLLocation(latitude: 23.0283, longitude: 72.5067)
    let distance = String(format: "%.2f km", userLocation.distanceFromLocation(priceLocation)/1000)
    print("Distance is KM is:: \(distance)")
    

提交回复
热议问题