【发布时间】:2015-10-26 11:44:50
【问题描述】:
我想在文本字段上输入时实现(自动完成)谷歌建议的地方如何使用 api 键实现它?
为此,我已经下载了适用于 ios 1.9.1 的 google map sdk 并将 api 密钥放入 AppDelegate.m 但我能够获得以下代码 -
【问题讨论】:
标签: iphone google-maps-sdk-ios
我想在文本字段上输入时实现(自动完成)谷歌建议的地方如何使用 api 键实现它?
为此,我已经下载了适用于 ios 1.9.1 的 google map sdk 并将 api 密钥放入 AppDelegate.m 但我能够获得以下代码 -
【问题讨论】:
标签: iphone google-maps-sdk-ios
在 -(void)textFieldDidBeginEditing:(UITextField *)textField 方法的 uitextfield 委托方法中,编写以下代码:-
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);
}
}];
【讨论】: