0
我正在開發像Uber和Careem這樣的應用程序。當用戶使用Google Places自動填充API搜索位置時,我想要顯示距離以及自動填充結果位置的名稱,例如優步和Careem這樣做。找到距離當前位置的自動完成結果位置的距離IOS
Plz have a look on this image for further clarification
我正在開發像Uber和Careem這樣的應用程序。當用戶使用Google Places自動填充API搜索位置時,我想要顯示距離以及自動填充結果位置的名稱,例如優步和Careem這樣做。找到距離當前位置的自動完成結果位置的距離IOS
Plz have a look on this image for further clarification
編輯:
其中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)
確實商家信息自動填充API返回的位置的座標也沒有反向地理編碼? –
不,你可以用place id來完成這個 –