我已经按照Google网站上的Places API教程进行了操作,并且我已经仔细检查过启用了适用于iOS的Places API以及我的API密钥是否在我的AppDelegate中.我已经在我的班级中实现了GMSPlacePickerViewControllerDelegate.地点选择器将打开,我可以查看地点,我可以点击它们,我可以搜索.我无法离开这个屏幕,我无法取消,我实际上无法选择任何东西或返回一个位置.这在物理设备和模拟器上是相同的.为什么它不起作用,我怎样才能使它工作?
@IBAction func selectLocationPressed(_ sender: Any) {
let config = GMSPlacePickerConfig(viewport: nil)
let placePicker = GMSPlacePickerViewController(config: config)
present(placePicker, animated: true, completion: nil)
}
// To receive the results from the place picker 'self' will need to conform to
// GMSPlacePickerViewControllerDelegate and implement this code.
func placePicker(_ viewController: GMSPlacePickerViewController,
didPick place: GMSPlace) {
// Dismiss the place picker, as it cannot dismiss itself.
viewController.dismiss(animated: true, completion: nil)
print("Place name \(place.name)")
print("Place address \(place.formattedAddress)")
print("Place attributions \(place.attributions)")
}
func placePickerDidCancel(_ …Run Code Online (Sandbox Code Playgroud)