0

I am having problems using Google Maps and Core Location. I have a screen which displays a map (with Google Maps) and the current location (Google Maps feature). When the map is loaded it shows my location and use of the location indicator appears (the one small arrow next to the battery). When I leave this screen the indicator is out and some not, that is, it is still using My Location.

In the situation described above when I use the location to another application screen, it generates me the following error:

Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

This happens with or without internet. From what I observed is like Google Maps to continue using my location. Often this error occurs but after a few seconds he continues to update, however when it occurs with Google Maps it is only releasing the error. And in this point assumming user authorized to share location.

Code:

Map - Google Maps - Latest version updated today - 10.14.2015

    let coordinates = CLLocationCoordinate2DMake(-12.000000, -53.1805017)
    let camera = GMSCameraPosition(target: coordinates, zoom: 3, bearing: 0, viewingAngle: 0)
    self.map.delegate = self
    self.map.camera = camera
    self.map.myLocationEnabled = true

Already tried to set myLocationEnabled false in view disappear, but without success.

CLLocationManager

The UIViewController defined CLLocationManagerDelegate.

self.locationManager = CLLocationManager()
self.locationManager.startUpdatingLocation()
self.locationManager.delegate = self
self.locationManager.distanceFilter = kCLDistanceFilterNone
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest

Delegate methods:

// MARK: - CLLocationManagerDelegate

    func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        let newLocation = locations.last
        self.performGeocodeAddress(newLocation!)
        self.locationManager.stopUpdatingLocation()
        print("Location has updated")
    }

    func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
        NSLog("Error update location: \(error.description)")
        self.locationManager.stopUpdatingLocation()
        self.locationManager.startUpdatingLocation()
    }
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Gian
  • 1,193
  • 2
  • 8
  • 20
  • Do you use simulator for testing? If so, you might reset your simulator, or use a real device for testing, you can check out [this StackOverflow post](http://stackoverflow.com/questions/6032976/didfailwitherror-error-domain-kclerrordomain-code-0-the-operation-couldn-t-be) for more details. – ztan Oct 15 '15 at 21:19
  • @ztan Testing in real device (iPad and iPhone 5). So, my application will unfortunately continue with this error? – Gian Oct 16 '15 at 12:46

0 Answers0