Reputation: 391
I am new to iOS development and am trying out a simple app using Google Maps SDK. I am following the steps listed on Google Maps Getting Started guide.
I have seen the similar question: Google Maps iOS SDK Integration not loading maps where the problem is with bundle ID. I made sure it is not the case for me.
I already spent 3 days trying new app from scratch.
I created a new api key, added my bundle ID.
I added API key:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
GMSServices.provideAPIKey("MYKEY")
return true
}
Following is the ViewController.swift:
import UIKit
import GoogleMaps
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
view = mapView
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20)
marker.title = "Sydney"
marker.snippet = "Australia"
marker.map = mapView
}
}
I ran it on simulator and real phone. I get the marker and Google logo but no map. Can some one give some clues?
Upvotes: 9
Views: 12591
Reputation: 676
Please make sure you generate the right api key before you run the project for the first time. 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
Upvotes: 2
Reputation: 391
Hi I found the issue and fixed the problem. The problem is with the API key - not code. Before IOS app, i was trying a sample android map app and i used the same console to create new api key without enabling google maps api for IOS.
Developers console somehow allows to add IOS restrictions on API key even though SDK for IOS is not enabled - because of this, I never thought I need to do anything more.
If you get this error and you already verified bundle ID is current, check the following:
-Kal
Upvotes: 30