I want to get current device location and zoom map to that coordinates.
I also wan't to stop location manager after zoom to user location to prevent changing map visible area if user move.
...viewDidLoad...{
self.locationManager = CLLocationManager();
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.mapView.showsUserLocation = true;
self.locationManager.startUpdatingLocation();
}
func locationManager(manager:CLLocationManager, didUpdateLocations locations:[AnyObject]){
var newRegion = MKCoordinateRegion(center: self.mapView.userLocation.coordinate, span: MKCoordinateSpanMake(0.014, 0.014));
self.mapView.setRegion(newRegion, animated: true);
self.locationManager.stopUpdatingLocation();
}
Problem with this code is that this code move map view to ocean and coordinates are sometimes invalid (another continent).
And as I stopped location manager map view stays in the ocean :-/
What is the proper way to make what I want?