gpt4 book ai didi

ios - 如何在 Google maps ios sdk 中过滤自动完成国家?

转载 作者:IT王子 更新时间:2023-10-29 05:46:51 24 4
gpt4 key购买 nike

目前,它在每个国家查询,但我希望它只在新加坡查询

我找到了一个stackoverflow解决方案How to get country specific result with Google autocomplete place api ios sdk? , 但不知道我应该把代码放在哪里。

这是代码,我使用全屏自动完成解决方案。

import UIKit
import GoogleMaps

class OnlyLocationViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}

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


@IBAction func clickMe(sender: UIButton) {
let autocompletecontroller = GMSAutocompleteViewController()
autocompletecontroller.delegate = self
self.presentViewController(autocompletecontroller, animated: true, completion: nil)


}

}

extension OnlyLocationViewController: GMSAutocompleteViewControllerDelegate{

func viewController(viewController: GMSAutocompleteViewController, didAutocompleteWithPlace place: GMSPlace) {
print("Place name: ", place.name)
print("Place address: ", place.formattedAddress)
print("Place attributions: ", place.attributions)

self.dismissViewControllerAnimated(true, completion: nil)
}


func viewController(viewController: GMSAutocompleteViewController, didFailAutocompleteWithError error: NSError) {
// To handle error
print(error)

}
func wasCancelled(viewController: GMSAutocompleteViewController) {
self.dismissViewControllerAnimated(true, completion: nil)
}

func didRequestAutocompletePredictions(viewController: GMSAutocompleteViewController) {
UIApplication.sharedApplication().networkActivityIndicatorVisible = true
}

func didUpdateAutocompletePredictions(viewController: GMSAutocompleteViewController) {
UIApplication.sharedApplication().networkActivityIndicatorVisible = false
}


}

我应该把过滤器代码放在哪里?

最佳答案

尝试使用这个

@IBAction func clickMe(sender: UIButton) {
let autocompletecontroller = GMSAutocompleteViewController()
autocompletecontroller.delegate = self
let filter = GMSAutocompleteFilter()
filter.type = .Establishment //suitable filter type
filter.country = "SG" //appropriate country code
autocompletecontroller.autocompleteFilter = filter
self.presentViewController(autocompletecontroller, animated: true, completion: nil)
}

关于ios - 如何在 Google maps ios sdk 中过滤自动完成国家?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37753742/

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