【问题标题】:GooglePlaces iOS, Can't load search resultsGooglePlaces iOS,无法加载搜索结果
【发布时间】:2017-01-23 18:38:28
【问题描述】:

GooglePlaces GMSAutocompleteViewController 停止搜索地点。

GMSPlacesClient 密钥设置正确,工作正常。

如果您对此问题有所了解,请提供帮助。谢谢。

【问题讨论】:

    标签: ios objective-c google-places-api


    【解决方案1】:

    您的 Google Places 密钥将过期,或者您插入了错误的密钥。请检查您的密钥

    import <GoogleMaps/GoogleMaps.h>
    
    #import "ViewController.h"
    
    @interface ViewController ()<GMSAutocompleteViewControllerDelegate>
    
    @end
    
    @implementation ViewController
    
    // TODO: Add a button to Main.storyboard to invoke onLaunchClicked:
    
    // Present the autocomplete view controller when the button is pressed.
    - (IBAction)onLaunchClicked:(id)sender {
      GMSAutocompleteViewController *acController = [[GMSAutocompleteViewController alloc] init];
      acController.delegate = self;
      [self presentViewController:acController animated:YES completion:nil];
    }
    
    // Handle the user's selection.
    - (void)viewController:(GMSAutocompleteViewController *)viewController
        didAutocompleteWithPlace:(GMSPlace *)place {
        // Do something with the selected place.
        NSLog(@"Place name %@", place.name);
        NSLog(@"Place address %@", place.formattedAddress);
        NSLog(@"Place attributions %@", place.attributions.string);
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    
    - (void)viewController:(GMSAutocompleteViewController *)viewController
        didFailAutocompleteWithError:(NSError *)error {
        // TODO: handle the error.
        NSLog(@"error: %ld", [error code]);
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    
    // User canceled the operation.
    - (void)wasCancelled:(GMSAutocompleteViewController *)viewController {
      NSLog(@"Autocomplete was cancelled.");
      [self dismissViewControllerAnimated:YES completion:nil];
    }
    
    @end
    

    访问 https://developers.google.com/places/ios-api/

    【讨论】:

      【解决方案2】:

      我也面临同样的问题。 我在我的信用卡添加帐户上制作了谷歌 API 密钥。但是那个键不能正常工作。 要解决此问题,请更新您的 pod

      【讨论】:

        猜你喜欢
        • 2018-02-01
        • 1970-01-01
        • 1970-01-01
        • 2020-01-28
        • 1970-01-01
        • 1970-01-01
        • 2019-01-05
        • 1970-01-01
        • 2020-03-16
        相关资源
        最近更新 更多