问题
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:
- Include curly braces. For some people it worked:
[GMSServices provideAPIKey:@"{MY-KEY}"];
Manually type the API key instead of copying & pasting the key. Sometimes some characters differs in copy paste procedure.
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