Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. class NearestDealerViewController: UIViewController, CLLocationManagerDelegate {
  2.  
  3. @IBOutlet weak var mainMenuLabel: UILabel!
  4. @IBOutlet weak var nearestDealer: UILabel!
  5. @IBOutlet weak var mapView: GMSMapView!
  6. let locationManager = CLLocationManager()
  7.  
  8. let transitionDelegate = TransitionDelegate()
  9. var delegate: NearestDealerViewControllerDelegate?
  10.  
  11. override func viewDidLoad() {
  12. super.viewDidLoad()
  13.  
  14. locationManager.delegate = self
  15. locationManager.requestWhenInUseAuthorization()
  16. println(mapView.myLocationEnabled)
  17. }
  18.  
  19. func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
  20. if status == .AuthorizedWhenInUse {
  21. locationManager.startUpdatingLocation()
  22. mapView.myLocationEnabled = true
  23. mapView.settings.myLocationButton = true
  24. }
  25. println(mapView.myLocationEnabled)
  26.  
  27. }
  28.  
  29. func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
  30. if let location = locations.first as? CLLocation {
  31. mapView.camera = GMSCameraPosition(target: location.coordinate, zoom: 15, bearing: 0, viewingAngle: 0)
  32. locationManager.stopUpdatingLocation()
  33. }
  34. }
  35.  
  36. @IBAction func backTapped(sender: AnyObject) {
  37. delegate?.dismissNearestDealerViewController()
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement