我想使用Google Map API在我的应用中显示当前位置。我在我们的项目中使用了谷歌地图API,我遵循了"这里"的所有步骤。
我还给出了正确的API密钥和捆绑标识符,但地图不仅加载了简单的空白和最后一个Google按钮显示。
我在"谷歌地图-iOS-1.9.1"的演示中使用相同的 API 密钥,它工作正常,但没有在我的应用程序上加载地图。
因此,请提供适用于我的代码的任何建议或源代码。
谢谢。
使用以下步骤:
在应用程序委托中:
- (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 的密钥