Actually there is no error in the code. but when I run my app the google maps does not shown In the simulator and in the outputs area or debugging show me this sentence Error Domain=kCLErrorDomain Code=1 "(null)
here is an image shown the simulator does have the google maps but it's not shown and when it's running it's show me this sentence Error Domain=kCLErrorDomain Code=1 "(null)
This is the code :
import UIKit import GoogleMaps
class ViewController: UIViewController,CLLocationManagerDelegate{
@IBOutlet weak var googleMap: GMSMapView!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
if CLLocationManager.locationServicesEnabled(){
locationManager.requestLocation()
}
else{
locationManager.requestWhenInUseAuthorization()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
googleMap.camera = GMSCameraPosition(target: CLLocationCoordinate2D(latitude: locationManager.location?.coordinate.latitude ?? 0.0, longitude: locationManager.location?.coordinate.longitude ?? 0.0), zoom: 8, bearing: 0, viewingAngle: 0)
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: locationManager.location?.coordinate.latitude ?? 0.0, longitude: locationManager.location?.coordinate.longitude ?? 0.0)
marker.title = "I'm here"
marker.snippet = "I'm here"
marker.map = googleMap
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error)
}
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
switch manager.authorizationStatus {
case .authorizedAlways:
return
case .authorizedWhenInUse:
return
case .denied:
return
case .restricted:
locationManager.requestWhenInUseAuthorization()
case .notDetermined:
locationManager.requestWhenInUseAuthorization()
default:
locationManager.requestWhenInUseAuthorization()
}
}
}
CodePudding user response:
I found the answer for this question The API Key for the GoogleMaps was not valid Thats it Simply I change the API Key