ios - 集成 google map api iOS 时 map 未加载

标签 ios objective-c iphone google-maps-api-3 google-maps-sdk-ios

我想使用 Google Map API 在我的应用中显示当前位置。 我在我们的项目中使用了 Google map API,我遵循了“here”中的所有步骤。

我还提供了正确的 API key 和包标识符,但 map 并未仅加载简单的空白和最后一个 Google 按钮显示。

而且我在“GoogleMaps-iOS-1.9.1”的演示中使用了相同的 API key ,它工作正常但没有在我的应用程序上加载 map 。

所以,请提供适用于我的代码的任何建议或源代码。

谢谢。

最佳答案

使用以下步骤:

在 AppDelegate 中:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Put your API key here.
    [GMSServices provideAPIKey:GOOGLE_PRJ_API_KEY];
    return YES;
}

在你的类中某处说 MapsController 使用下面的代码将会出现:

- (void)setupGoogleMap{
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:_currentLocation.coordinate.latitude longitude:_currentLocation.coordinate.longitude zoom:DEFAULT_ZOOM_LEVEL];
    if (!_googleMapView) {
        _googleMapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
        [self.view insertSubview:_googleMapView atIndex:0];
        _googleMapView.settings.compassButton = YES;
        _googleMapView.myLocationEnabled = YES;
        [_googleMapView setDelegate:self];
    }
    _googleMapView.camera = camera;
}

请检查您提供的 API key 或尝试重新生成或设置仅 iOS key 和包标识符

关于ios - 集成 google map api iOS 时 map 未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28277156/

相关文章:

iphone - 增加框架时自动调整 mask 大小问题 - iOS

objective-c - 使用 Erica Sadun 示例的 UIImageView 调整大小和旋转问题 - 预填充位置

objective-c - 许多功能已弃用 - iOs 6

ios - objective-c 使用 AutoResizingMask 将 UILabe 对齐到 UitableViewCell 内部

iphone - 无法检索同时触摸的数量

iphone - 如何只获取域名?

ios - Apple 收据设备哈希验证

ios - AVPlayerViewController PIP...如何返回应用程序?

objective-c - 无法从 Swift 访问桥接的 NSArray

iphone - 将视频从 iPhone 或 Android 流式传输到 RTMP