缺少地图,仅可见标记 [英] Missing Map, only marker is visible

查看:124
本文介绍了缺少地图,仅可见标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难找出问题所在.我在SO上也遇到了类似的问题,但是这里提到的解决方案没有用.一种流行的解决方案是启用"iOS版Google Maps SDK",但是在我的案例中已经启用了它:

I am having a hard time trying to figure out what is going wrong. I have gone through similar questions on SO, but the solutions mentioned here did not work. One of the popular solution was to enable the 'Google Maps SDK for iOS', however it was already enabled in my case:

我认为我已经照顾好Google教程中提到的所有内容,但是当我在模拟器中运行我的应用程序时,会发生这种情况:

I think I have taken care of everything mentioned in the tutorial by Google, but when I run my app in simulator, this happens :

然后我检查了控制台以找到以下内容:

Then I checked my console to find this:

我在生成密钥时检查了我的bundle ID输入的内容,它是正确的,而且在AppDelegate.m中输入的密钥也没有错.有人可以帮我弄这个吗.预先感谢.

I checked my bundle ID to what I entered while generating the key and it's correct, also the key entered in AppDelegate.m isn't wrong. Can someone help me with this. Thanks in advance.

AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[GMSServices provideAPIKey:@"MY-KEY"]; 

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[ViewController alloc] init];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

return YES;
}

ViewController.m:

- (void)viewDidLoad {
[super viewDidLoad];

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                        longitude:151.20
                                                             zoom:6];
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];

mapView.myLocationEnabled = YES;
self.view = mapView;

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView;
[self.view layoutIfNeeded];
}

推荐答案

再次检查您的Google服务密钥,即有效密钥是否无效. 键无效,未显示地图.

once again check your google service key that is valid key are not. key is not valid map is not showed.

[GMSServices provideAPIKey:@"AIzaSyXXXXXXXXXXXXXXXXXXXXXX"];

这篇关于缺少地图,仅可见标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆