Reputation: 12034
I'm trying to implement a simple google maps using swift.
The map should be displayed in a UIView
.
Well, I follow the next steps:
I added a UIView
element in my storyboard with the class GMSMapView
And declared in my ViewController
with:
@IBOutlet weak var mapView: GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
let camera = GMSCameraPosition.camera(withLatitude: 51.050657, longitude: 10.649514, zoom: 5.5)
let map = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
self.mapView = map
}
And GMSServices.provideAPIKey("xxx-xxx")
in my AppDelegate.swift
.
Ok, those codes aren't returning any error, but in my screen it's displayed the Google text in colors and a gray background without the map.
What I'm doing wrong?
Upvotes: 4
Views: 3573
Reputation: 11
This issue may also occur if your API Key is not properly configured in AppDelegate.m in IOS and AndroidManifest.XML in Android
AppDelegate.m
GMSServices provideAPIKey:@"XXXXYOUR-API-KEYXXX"]; // check "YOUR_API_KEY" underscore is removed.
Upvotes: 1
Reputation: 1296
This issue occur when the Google Maps SDK is not enable for your API Key . For enabling it , open your developer console at https://console.developers.google.com . On the left handside select library. Select Google Map SDK for iOS under Google Maps Api heading and click enable for enabling the Google Map SDK . That's it , you will now have your same old beautiful maps.
Upvotes: 19