API带有内部错误的放置



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

我遇到了这个错误。我能够工作几个小时。代码没有任何更改。一段时间后,我会收到每个请求的上述错误

我使用的一些代码

- (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];
}

我们需要为gsmplacesclient提供api_key,就像 GMSPlacesClient.provideAPIKey("Your_APIKey")一样

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

swift 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() }
        }
    }
}

几天后,我知道它将为每天的一定数量搜索提供结果。我有一天会出现上述错误。在第二天没有可行的代码更改。

相关内容

最新更新