Guest User

Untitled

a guest
Aug 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import UIKit
  2. import MapKit
  3. import CoreLocation
  4.  
  5. class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
  6.  
  7. @IBOutlet weak var mapView: MKMapView!
  8. var manager = CLLocationManager()
  9.  
  10. override func viewDidLoad() {
  11. super.viewDidLoad()
  12. // add the some text to your plist entry: "Privacy - Location When In Use Usage Description"
  13. manager.requestWhenInUseAuthorization()
  14. }
  15.  
  16. func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
  17. if status == CLAuthorizationStatus.authorizedWhenInUse || status == CLAuthorizationStatus.authorizedAlways {
  18. mapView.mapType = MKMapType.standard
  19. mapView.delegate = self
  20. mapView.showsTraffic = true
  21. mapView.showsUserLocation = true
  22. mapView.setUserTrackingMode(MKUserTrackingMode.followWithHeading, animated: true)
  23. }
  24. }
  25. }
Add Comment
Please, Sign In to add comment