Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class NearestDealerViewController: UIViewController, CLLocationManagerDelegate {
- @IBOutlet weak var mainMenuLabel: UILabel!
- @IBOutlet weak var nearestDealer: UILabel!
- @IBOutlet weak var mapView: GMSMapView!
- let locationManager = CLLocationManager()
- let transitionDelegate = TransitionDelegate()
- var delegate: NearestDealerViewControllerDelegate?
- override func viewDidLoad() {
- super.viewDidLoad()
- locationManager.delegate = self
- locationManager.requestWhenInUseAuthorization()
- println(mapView.myLocationEnabled)
- }
- func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
- if status == .AuthorizedWhenInUse {
- locationManager.startUpdatingLocation()
- mapView.myLocationEnabled = true
- mapView.settings.myLocationButton = true
- }
- println(mapView.myLocationEnabled)
- }
- func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
- if let location = locations.first as? CLLocation {
- mapView.camera = GMSCameraPosition(target: location.coordinate, zoom: 15, bearing: 0, viewingAngle: 0)
- locationManager.stopUpdatingLocation()
- }
- }
- @IBAction func backTapped(sender: AnyObject) {
- delegate?.dismissNearestDealerViewController()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement