Reputation: 853
i want to implement (Auto Complete) suggested places of google while typing on textfield how to implement it using api key ?
for that i have downloaded google map sdk for ios 1.9.1 and put the api key into AppDelegate.m but i am anable to get the code following -
https://developers.google.com/places/ios-api/autocomplete
Upvotes: 3
Views: 403
Reputation: 2678
Inside your -(void)textFieldDidBeginEditing:(UITextField *)textField method of uitextfield delegate methods, write the below code:-
GMSPlacesClient *placesClient= [[GMSPlacesClient alloc] init];
[placesClient autocompleteQuery:textField.text bounds:nil
filter:kGMSPlacesAutocompleteTypeFilterNoFilter
callback:^(NSArray *results, NSError *error) {
if (error != nil) {
NSLog(@"Autocomplete error %@", [error localizedDescription]);
return;
}
for (GMSAutocompletePrediction* result in results) {
NSLog(@"Result '%@' with placeID %@", result.attributedFullText.string, result.placeID);
}
}];
Upvotes: 0