我正在开发像Uber和Careem这样的应用程序。当用户使用Google商家信息自动填充API搜索某个位置时,我想显示距离以及自动完成的名称,例如Uber和Careem会这样做。
答案 0 :(得分:0)
编辑:
其中cuGMS是 GMSAutocompletePrediction
的数组 let cuGMS = self.resultsArray[indexPath.row]
let placesClient = GMSPlacesClient()
placesClient.lookUpPlaceID(cuGMS.placeID!, callback: { (response , error) in
print("response \(response)")
if(error == nil)
{
let coor = response?.coordinate
let lat = coor?.latitude
let lon = coor?.longitude
}
else
{
}
})
试试这个
let loc1:CLLocation = CLLocation.init(latitude: 30.0000, longitude:29.2545)
let loc2:CLLocation = CLLocation.init(latitude: 28.02002, longitude:27.00021)
let dis = loc1.distance(from: loc2)