I'v tried GMSPlacesClient but I couldn't get results in correct format to fill'em in tableView.
after that I used Fetcher but i didnt help me.
extension SearchViewController: GMSAutocompleteFetcherDelegate {
func didAutocomplete(with predictions: [GMSAutocompletePrediction]) {
let resultsStr = NSMutableString()
for prediction in predictions {
resultsStr.appendFormat("%@\n", prediction.attributedPrimaryText)
}
print(resultsStr as String)
}
func didFailAutocompleteWithError(_ error: Error) {
print(error.localizedDescription)
}
}
i don't know if i didn't understand it's usage. someone maybe describes me how to use Google Places Api to search Address in textBox and then show results in tableView.
My problem is onely getting results of search?
fetch Part Code:
var fetcher: GMSAutocompleteFetcher?
func placeAutocomplete(add:String) {
fetcher?.sourceTextHasChanged(add)
}
override func viewDidLoad() {
super.viewDidLoad()
tblView.delegate = self
tblView.dataSource = self
let filter = GMSAutocompleteFilter()
filter.type = .establishment
// Create the fetcher.
fetcher = GMSAutocompleteFetcher(bounds: nil, filter: filter)
fetcher?.delegate = self
}
result for search "Mex"
> Me{
GMSAutocompleteMatch = "<GMSAutocompleteMatchFragment: 0x60800043db60>";
}rcado de La Boqueria, La Rambla, Barcelona, Spain{
}*
Me{
GMSAutocompleteMatch = "<GMSAutocompleteMatchFragment:
0x60800043db60>";
}rcado San Anton, Calle de Augusto Figueroa, Madrid, Spain{
}*
Me{
GMSAutocompleteMatch = "<GMSAutocompleteMatchFragment: 0x60800043db60>";
}nlyn Mall, Atterbury Road, Pretoria, South Africa{
}*
Me{
GMSAutocompleteMatch = "<GMSAutocompleteMatchFragment:
0x60800043db60>";
}ga Mall, Bulevardul Pierre de Coubertin, Bucharest, Romania{
}*
Me{
GMSAutocompleteMatch = "<GMSAutocompleteMatchFragment:
0x60800043db60>";
}rcado de San Ildefonso, Calle de Fuencarral, Madrid, Spain{
}*
print code :
for q in predictions1
{
print ( "\(q.attributedFullText)*")
}
you should use array for results instead of let resultsStr = NSMutableString()
and populate table view with data source as array