I am trying to work with google maps and everything was working fine until i add these two functions for getting updated Location.
func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus)
{
if (status == CLAuthorizationStatus.AuthorizedWhenInUse)
{
vwGMap.myLocationEnabled = true
}
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
let newLocation = locations.last
vwGMap.camera = GMSCameraPosition.cameraWithTarget(newLocation!.coordinate, zoom: 15.0)
vwGMap.settings.myLocationButton = true
self.view = self.vwGMap
}
Now, when i am trying to execute my app, there is an crash with exception "Terminating app due to uncaught exception 'GMSServicesException', reason: 'Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use"
My API key is valid and already placed in Appdelegate. Anyone, Has any Idea what i am doing wrong here?
I am also presenting my viewDidLoad Code of my ViewController
let camera = GMSCameraPosition.cameraWithLatitude(-33.8683,
longitude: 151.2086, zoom: 15)
let mapView = GMSMapView.mapWithFrame(self.view.bounds, camera: camera)
mapView.setMinZoom(8, maxZoom: 18)
mapView.indoorEnabled = false
mapView.settings.compassButton = true
mapView.settings.myLocationButton = true
mapView.myLocationEnabled = true
mapView.camera = camera
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer
locationManager.distanceFilter = 500
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
self.view = mapView