你好我在我的
IOS应用程序中使用谷歌自动完成位置.但问题是它不起作用.而且我无法获得用户的当前位置.
搜索功能成功显示自动填充框中的位置,但我遇到的唯一问题是无法获取用户的当前位置.这是获取用户当前位置的代码我正在使用
class ViewController: UIViewController,CLLocationManagerDelegate { var locationManager = CLLocationManager() var placesClient : GMSPlacesClient? override func viewDidLoad() { super.viewDidLoad() locationManager.requestAlwaysAuthorization() run() } func run(){ self.placesClient?.currentPlaceWithCallback({ (list: GMSPlaceLikelihoodList?,error: NSError?) -> Void in if let error = error { print("error: \(error.description)") return } for likelihood in list!.likelihoods { if let likelihood = likelihood as? GMSPlaceLikelihood { let place = likelihood.place print("Current Place name \(place.name) at likelihood \(likelihood.likelihood)") print("Current Place address \(place.formattedAddress)") print("Current Place attributions \(place.attributions)") print("Current PlaceID \(place.placeID)") } } }) }
我也在info.plist中添加了密钥,我正在手机上编译应用程序.