Missing Map, only marker is visible

試著忘記壹切 提交于 2019-12-13 07:45:20

问题


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:

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:

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];
}

回答1:


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

[GMSServices provideAPIKey:@"AIzaSyXXXXXXXXXXXXXXXXXXXXXX"];



回答2:


Here are few things you can try:

  1. Include curly braces. For some people it worked:

[GMSServices provideAPIKey:@"{MY-KEY}"];

  1. Manually type the API key instead of copying & pasting the key. Sometimes some characters differs in copy paste procedure.

  2. If nothing works, make a fresh start.




回答3:


I faced the similar issue and fixed it by generating and enabling the right APIKey for iOS (and not javascript or android) using this link -- APIKey for iOS



来源:https://stackoverflow.com/questions/40674743/missing-map-only-marker-is-visible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!