 //
 
 import UIKit
+import MapKit
 import CoreLocation
 
 class ViewController: UIViewController {
 
     // MARK: - ivars
     
+    internal var _mapView: MKMapView?
     internal var _permissionLocationButton: UIButton?
     internal var _locationLookupButton: UIButton?
     

extension ViewController: PositionObserver {

    func position(_ position: Position, didChangeLocationAuthorizationStatus status: LocationAuthorizationStatus) {
        // location authorization did change, often this may even be triggered on application resume if the user updated settings
        print("location authorization status \(status)")
    }
	

        super.viewDidLoad()

        self.view.autoresizingMask = ([UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight])
        self.view.backgroundColor = UIColor.lightGray
        
        self._mapView = MKMapView(frame: self.view.bounds)
        if let mapView = self._mapView {
            self.view.addSubview(mapView)
        }
        
        self._locationLookupButton = UIButton(frame: CGRect(x: 0, y: self.view.bounds.size.height - 50, width: self.view.bounds.size.width, height: 50))
        if let locationButton = self._locationLookupButton {
            locationButton.autoresizingMask = [.flexibleWidth, .flexibleTopMargin]
            locationButton.setTitle("Request Location", for: UIControlState())
            locationButton.titleLabel!.font = UIFont(name: "AvenirNext-Regular", size: 16)
            locationButton.backgroundColor = UIColor(red: 115/255, green: 57/255, blue: 248/255, alpha: 1)
            locationButton.addTarget(self, action: #selector(ViewController.handleOneShotLocationButton(_:)), for: .touchUpInside)
            self.view.addSubview(locationButton)
        }
        
        self._permissionLocationButton = UIButton(frame: CGRect(x: 0, y: self.view.bounds.size.height - 100, width: self.view.bounds.size.width, height: 50))
        if let permissionLocationButton = self._permissionLocationButton {
            permissionLocationButton.setTitle("Request Permission", for: UIControlState())
            permissionLocationButton.titleLabel!.font = UIFont(name: "AvenirNext-Regular", size: 16)
            permissionLocationButton.backgroundColor = UIColor(red: 50/255, green: 153/255, blue: 252/255, alpha: 1)
            permissionLocationButton.addTarget(self, action: #selector(handleLocationPermissionButton(_:)), for: .touchUpInside)
            self.view.addSubview(permissionLocationButton)
        }
        
        // setup position
        
