【问题标题】:Place api gives with internal errorPlace api 给出内部错误
【发布时间】:2016-06-24 06:07:34
【问题描述】:

操作无法完成。 Places API 库中发生内部错误。如果您认为此错误代表错误,请使用我们社区和支持页面 (https://developers.google.com/places/support) 上的说明提交报告。

我收到此错误。我能够工作几个小时。代码没有任何变化。一段时间后,每个请求我都会收到上述错误

我在 iOS 中使用的一些代码

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    NSString *text = [textField text];
    text = [text stringByReplacingCharactersInRange:range withString:string];
    if (text.length>0) {
        footerView.hidden = NO;
        [footerView startAnimating];
    }else {
        [self removeDropDown];
        return YES;
    }
    [_fetcher sourceTextHasChanged:text];
    return YES;
}

委托方法

- (void)didAutocompleteWithPredictions:(NSArray *)predictions {
    resultsArray = [[NSMutableArray alloc]init];
    NSMutableArray *titlesArray = [[NSMutableArray alloc]init];
    for (GMSAutocompletePrediction *prediction in predictions) {
        [titlesArray addObject:[prediction.attributedPrimaryText string]];
        [resultsArray addObject:prediction];
    }

    if (self.searchTextField.text.length>0) {
        if (dropDown == nil) {
            dropDown = [[PTDropDownView alloc] showDropDown:self.searchParentView withheight:autoCompleteViewMaxHeight withItems:titlesArray animationDirection:DirectionDown];
            dropDown.delegate = self;
        } else {
            dropDown.itemsArray = titlesArray;
            [dropDown.tableView reloadData];
        }
        dropDown.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.4];
        [self adjustDropDownFrame];

        [footerView stopAnimating];
    }

    NSLog(@"fetched count = %d",resultsArray.count);

}

- (void)didFailAutocompleteWithError:(NSError *)error {

        NSLog(@"%@",[NSString stringWithFormat:@"%@", error.localizedDescription]);
    [self removeDropDown];
}

【问题讨论】:

  • 也许有新的更新可用。尝试使用最新的 pod 版本

标签: ios google-places-api ios9.3


【解决方案1】:

我们需要为 GSMPlacesClient 提供 API_Key,例如 GMSPlacesClient.provideAPIKey("Your_APIKey"),就像我们为 GMSServices 提供的一样

【讨论】:

    【解决方案2】:

    我能够通过确保没有发送空查询来解决错误。请注意,我没有使用 GMSAutoCompleteFetcher() 包装器,而是使用共享的 GMSPlacesClient 来获取预测。

    斯威夫特 2:

        func autocompleteQuery(withQuery query: String) {
        if !query.isEmpty {
            placesClient.autocompleteQuery(query, bounds: self.bounds, filter: .None) { results, error in
                guard error == nil else {
                    print("Autocomplete error \(error)")
                    return
                }
                self.predictions = results!
                dispatch_async(dispatch_get_main_queue()) { self.autocompleteResultsTableView.reloadData() }
            }
        }
    }
    

    【讨论】:

      【解决方案3】:

      几天后,我知道它每天会给出一定数量的搜索结果。我在一天之内收到了上述错误。第二天无需更改代码即可运行。

      【讨论】:

      • 这似乎是正确的解决方案,尽管它并不是真正达到目的的手段。我目前正在解决与 Google Places API 完全相同的问题,并且我的代码库中没有任何变化。我想知道内部错误可能是什么,以及它是否与我的 Xcode 版本或一般的 Xcode 有关。
      猜你喜欢
      • 2014-10-16
      • 1970-01-01
      • 2014-11-12
      • 1970-01-01
      • 1970-01-01
      • 2015-04-08
      • 2016-11-08
      • 2018-01-02
      • 1970-01-01
      相关资源
      最近更新 更多