Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. let manager = CLLocationManager()
  2.  
  3. func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
  4.  
  5. let location = locations[0]
  6.  
  7. let span:MKCoordinateSpan = MKCoordinateSpanMake(0.01, 0.01)
  8. let actLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude)
  9. let region:MKCoordinateRegion = MKCoordinateRegionMake(actLocation, span)
  10. map.setRegion(region, animated: true)
  11.  
  12. self.map.showsUserLocation = true
  13. }
  14.  
  15. override func viewDidLoad()
  16. {
  17. super.viewDidLoad()
  18.  
  19. manager.delegate = self
  20. manager.desiredAccuracy = kCLLocationAccuracyBest
  21. manager.requestWhenInUseAuthorization()
  22. manager.startUpdatingLocation()
  23.  
  24. }
  25.  
  26. override func didReceiveMemoryWarning() {
  27. super.didReceiveMemoryWarning()
  28. }
  29.  
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement