Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) -> CLLocation {
- let currentLocation: CLLocation = locations[0] as CLLocation
- let lat = currentLocation.coordinate.latitude
- let long = currentLocation.coordinate.longitude
- let center = CLLocationCoordinate2D(latitude: currentLocation.coordinate.latitude, longitude: currentLocation.coordinate.longitude)
- let latDelta = 0.05
- let longDelta = 0.05
- let currentLocationSpan:MKCoordinateSpan =
- MKCoordinateSpanMake(latDelta, longDelta)
- let region = MKCoordinateRegion(center: center, span: currentLocationSpan)
- myMapView.setRegion(region, animated: true)
- let myAnnotation: MKPointAnnotation = MKPointAnnotation()
- myAnnotation.coordinate = CLLocationCoordinate2D(latitude: currentLocation.coordinate.latitude, longitude: currentLocation.coordinate.longitude)
- myAnnotation.title = "Current Location"
- myMapView.addAnnotation(myAnnotation)
- print("The latitude is (lat)")
- print("The longitude is(long)")
- print(currentLocation)
- return currentLocation
- }
- class ViewControllerB: ViewControllerA {
- override func viewDidLoad() {
- super.viewDidLoad()
- let center = CLLocationCoordinate2D(latitude:currentLocation.coordinate.latitude, longitude:currentLocation.coordinate.longitude)
- class ViewControllerB: ViewControllerA {
- let currentLocation: CLLocation? = nil
- override func viewDidLoad() {
- super.viewDidLoad()
- guard let currentLocation = currentLocation else { return }
- let center = CLLocationCoordinate2D(latitude:currentLocation.coordinate.latitude, longitude:currentLocation.coordinate.longitude)
- }
- viewControllerB.currentLocation = currentLocation
Add Comment
Please, Sign In to add comment