I am using google place auto complete API to search addresses in my app. I wanted to restrict google place auto complete results to specific city (i.e searching addresses in new york only).
I know this can be done through the Bound coordinates but I don't know how to find it (i.e New york specific bound coordinates)
I searched through the documentation for how to restrict results to specific city(i.e New york only) but it's very confusing.
Note: I am using GMSAutoCompleteController for google auto complete API.
Please let me know how to accomplish it.
// Code :
@IBAction func textfieldDidTapped(_ sender: Any) {
listingAddressTextfield.resignFirstResponder()
let controller = GMSAutocompleteViewController()
let filter = GMSAutocompleteFilter()
filter.type = .address
controller.autocompleteFilter = filter
controller.delegate = self
present(controller, animated: true, completion: nil)
}
// Delegate Methods...
extension ViewController: GMSAutocompleteViewControllerDelegate {
func viewController(_ viewController: GMSAutocompleteViewController, didAutocompleteWith place: GMSPlace) {
listingAddressTextfield.text = place.name
dismiss(animated: true, completion: nil)
}
func viewController(_ viewController: GMSAutocompleteViewController, didFailAutocompleteWithError error: Error) {
print("Error: ", error.localizedDescription)
}
func wasCancelled(_ viewController: GMSAutocompleteViewController) {
dismiss(animated: true, completion: nil)
}
}