Reputation: 309
This is my first time that I am using Google API. I am having problem implementing Google places auto-complete API in my project. I am using the Google developers link to Google Places Autocomplete API as reference.
I am able to implement the this tutorial correctly, however, I am unable to implement this in iOS.
Can someone please direct me to some tutorial in this regard? Basically I want to do the following:
When the user enters a text in UITextField,
Any help is in this regard will be highly appreciated. I am stuck on this problem for the past week.
Upvotes: 8
Views: 19475
Reputation: 3526
Google Api Helper (Autocomplete)
var input = GInput()
input.keyword = "San francisco"
GoogleApi.shared.callApi(input: input) { (response) in
if let results = response.data as? [GApiResponse.Autocomplete], response.isValidFor(.autocomplete) {
//Enjoy the Autocomplete Api
} else { print(response.error ?? "ERROR") }
}
Google Api Helper (Place Information)
var input = GInput()
input.keyword = "chijucwgqk6mqtkrukvhclvqfie"
GoogleApi.shared.callApi(.placeInformation,input: input) { (response) in
if let place = response.data as? GApiResponse.PlaceInfo, response.isValidFor(.placeInformation) {
//Enjoy the Place Api
} else { print(response.error ?? "ERROR") }
}
Google Api Helper (Many more)
https://github.com/tryWabbit/Google-Api-Helper
Upvotes: 0
Reputation: 143
And here's a Swift version :)
https://github.com/watsonbox/ios_google_places_autocomplete
Upvotes: 5
Reputation: 877
If you're looking for a great way to understand how to implement the Google Places Autocomplete feature, I would recommend looking at the example below:
https://github.com/AdamBCo/GooglePlacesAutocomplete
Upvotes: 0
Reputation: 8224
And another alternative: https://github.com/TarasRoshko/TRAutocompleteView
Can be binded to any existing UITextField in single line of code. Supports customization, configurable. Should be good pick for UITextFields, handles resizing and orientation automatically. I've created it because all existing solutions do not provide simple drop down list for text field, but whole separate views, or even "placeholder text suggestion", sometimes even without a possibility to actually autocomplete.
Upvotes: 4
Reputation: 836
Check out https://github.com/spoletto/SPGooglePlacesAutocomplete
It's an objective-c wrapper for the Google Places Autocomplete API.
Good Luck!
Upvotes: 22