【问题标题】:map not loading when integrating google map api iOS集成 google map api iOS 时地图未加载
【发布时间】:2015-04-01 08:45:03
【问题描述】:

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

我还提供了正确的 API 密钥和包标识符,但地图不仅加载了简单的空白和最后一个 Google 按钮显示。

我在“GoogleMaps-iOS-1.9.1”的演示中使用了相同的 API 密钥,它工作正常,但没有在我的应用上加载地图。

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

谢谢。

【问题讨论】:

  • 您是否在 Google 地图仪表板上添加了应用程序包 ID?

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


【解决方案1】:

使用以下步骤:

在 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 密钥或尝试重新生成或设置带有捆绑标识符的仅 iOS 密钥

【讨论】:

    猜你喜欢
    • 2013-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-07
    • 2017-04-10
    • 2013-03-19
    • 1970-01-01
    相关资源
    最近更新 更多