我想使用 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/