尝试在我的iOS应用中调用google map时,为什么会收到“ Error Domain = NSURLErrorDomain Code = -1004“无法连接到服务器。”错误?

时间:2019-04-17 06:01:35

标签: ios google-maps cllocationmanager api-key

Dashboard og my Google cloud platform每次在我的iOS应用中调用google map时,每次都会出错:

bcrypt

我试图添加ATS密钥,但是我得到了 我的应用出现load failed with error Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x283671e90 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <27BC82BB-492A-4C55-B351-35C2E91B2607>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <27BC82BB-492A-4C55-B351-35C2E91B2607>.<1>" ), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://clients4.google.com/glm/mmap, NSErrorFailingURLKey=https://clients4.google.com/glm/mmap, _kCFStreamErrorDomainKey=1} [-1004] ”错误。我曾在不同的网络中尝试过,但仍然是同一问题。知道为什么会发生这种问题吗?

我已经从git下载了基本示例代码,并尝试了我的API密钥。我删除了iOS捆绑包标识符限制,以便可以在演示应用程序中使用。我还将演示捆绑包标识符添加到我的api密钥中进行检查。没有任何效果,我无法在屏幕上看到地图。 请注意,我正在使用Google提供的1年试用API密钥来执行测试。

从代码中显示地图的调用如下:

Domain=NSURLErrorDomain Code=-1001 "Request timed out.中:-

viewDidLoad

,然后在CLLocationManager *locationManager = [[CLLocationManager alloc] init]; self._locationManager =locationManager; self._locationManager.distanceFilter = kCLDistanceFilterNone; self._locationManager.desiredAccuracy = kCLLocationAccuracyBest; [self._locationManager startUpdatingLocation]; [self._locationManager requestWhenInUseAuthorization]; [self._locationManager requestAlwaysAuthorization]; GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:self._locationManager.location.coordinate.latitude longitude:self._locationManager.location.coordinate.longitude zoom:15]; self.mapView_ = [GMSMapView mapWithFrame:CGRectMake(0, 44, 1024,724) camera:camera]; self.mapView_.delegate=self; self.mapView_.myLocationEnabled = YES; self.mapView_.settings.compassButton = YES; self.mapView_.settings.myLocationButton = YES; self.mapView_.accessibilityElementsHidden = NO; TestTileLayer *titleLayer = [[TestTileLayer alloc] init]; self.testTileLayer = titleLayer; self.testTileLayer.map = self.mapView_; [self.view addSubview:self.mapView_] ; [self showPinFromLocation]; 中:-

showPinFromLocation

我希望数据能够成功获取,并且完成处理程序可以进入数据块。但是,呼叫现在总是进入错误块。它根本没有进入数据块。

0 个答案:

没有答案