Guest User

Untitled

a guest
Apr 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) -> CLLocation {
  2.  
  3. let currentLocation: CLLocation = locations[0] as CLLocation
  4. let lat = currentLocation.coordinate.latitude
  5. let long = currentLocation.coordinate.longitude
  6. let center = CLLocationCoordinate2D(latitude: currentLocation.coordinate.latitude, longitude: currentLocation.coordinate.longitude)
  7. let latDelta = 0.05
  8. let longDelta = 0.05
  9. let currentLocationSpan:MKCoordinateSpan =
  10. MKCoordinateSpanMake(latDelta, longDelta)
  11. let region = MKCoordinateRegion(center: center, span: currentLocationSpan)
  12.  
  13. myMapView.setRegion(region, animated: true)
  14.  
  15. let myAnnotation: MKPointAnnotation = MKPointAnnotation()
  16. myAnnotation.coordinate = CLLocationCoordinate2D(latitude: currentLocation.coordinate.latitude, longitude: currentLocation.coordinate.longitude)
  17. myAnnotation.title = "Current Location"
  18. myMapView.addAnnotation(myAnnotation)
  19.  
  20. print("The latitude is (lat)")
  21. print("The longitude is(long)")
  22. print(currentLocation)
  23.  
  24. return currentLocation
  25.  
  26. }
  27.  
  28. class ViewControllerB: ViewControllerA {
  29.  
  30. override func viewDidLoad() {
  31.  
  32. super.viewDidLoad()
  33.  
  34. let center = CLLocationCoordinate2D(latitude:currentLocation.coordinate.latitude, longitude:currentLocation.coordinate.longitude)
  35.  
  36. class ViewControllerB: ViewControllerA {
  37.  
  38. let currentLocation: CLLocation? = nil
  39.  
  40. override func viewDidLoad() {
  41.  
  42. super.viewDidLoad()
  43. guard let currentLocation = currentLocation else { return }
  44. let center = CLLocationCoordinate2D(latitude:currentLocation.coordinate.latitude, longitude:currentLocation.coordinate.longitude)
  45. }
  46.  
  47. viewControllerB.currentLocation = currentLocation
Add Comment
Please, Sign In to add comment