gpt4 book ai didi

swift - 选择地点错误 - Google Places API

转载 作者:搜寻专家 更新时间:2023-10-30 22:18:23 25 4
gpt4 key购买 nike

我的代码出现此错误,我已逐步按照谷歌教程说明进行操作。

Pick Place error: The operation couldn’t be completed. The Places API could not find the user's location. This may be because the user has not allowed the application to access location information.

我已经将相关信息添加到 info.plist 中,我的代码如下所示 -

import UIKit
import GooglePlaces

class ViewController: UIViewController {

var placesClient: GMSPlacesClient!

@IBOutlet var nameLabel: UILabel!
@IBOutlet var addressLabel: UILabel!

override func viewDidLoad() {
super.viewDidLoad()
let locationManager = CLLocationManager()
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
placesClient = GMSPlacesClient.shared()
}

@IBAction func getCurrentPlace(_ sender: UIButton) {


placesClient.currentPlace(callback: { (placeLikelihoodList, error) -> Void in
if let error = error {
print("Pick Place error: \(error.localizedDescription)")
return
}

self.nameLabel.text = "No current place"
self.addressLabel.text = ""

if let placeLikelihoodList = placeLikelihoodList {
let place = placeLikelihoodList.likelihoods.first?.place
if let place = place {
self.nameLabel.text = place.name
self.addressLabel.text = place.formattedAddress?.components(separatedBy: ", ")
.joined(separator: "\n")
}
}
}
)
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}



}

带有允许/拒绝的位置窗口消失得太快,即使我按下允许也没有任何反应,我不知道如何解决这个问题,因为我只是在关注谷歌文档。

此外出现此错误 -

2017-03-26 14:38:27.472739 Restaurant[26616:2797750] subsystem: com.apple.BackBoardServices.fence, category: Observer, enable_level: 1, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0, enable_private_data: 0

最佳答案

您需要检查 https://console.developers.google.com 上的请求限制,免费版本每天只有 1000 个,我必须创建另一个项目和新 key 以继续测试。

关于swift - 选择地点错误 - Google Places API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43029481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com