I am trying to implement Google Maps SKD to an iOS app.
The location dot, google logo, and go to my location button are visible, but not the maps.
I try different thinks but none of those works.
My code is:
AppDelegate
import GoogleMaps
import GoogleNavigation
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
GMSServices.provideAPIKey("MY_KEY")
return true
}
....
ViewController
import UIKit
import GoogleMaps
import GoogleNavigation
class ViewController: UIViewController, CLLocationManagerDelegate {
private let locationManager = CLLocationManager()
@IBOutlet fileprivate weak var mapView: GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
guard status == .authorizedWhenInUse else {
return
}
locationManager.startUpdatingLocation()
mapView.isMyLocationEnabled = true
mapView.settings.myLocationButton = true
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let location = locations.first else {
return
}
mapView.camera = GMSCameraPosition(target: location.coordinate, zoom: 15, bearing: 0, viewingAngle: 0)
locationManager.stopUpdatingLocation()
}
}
In the console.cloud.google.com I set the project and the API key
and set the bundle ID.
I also have a billing account added to a project.
All other posts suggest:
- The incorrect map_key -> I checked that I copied the correct key.
- Not billing account -> I have one
What could be wrong here?
Xcode : 15.4
iOS : 15.0
map sdk: 9.0.0.0