 //
-//  MapViewViewController.swift
+//  MapVC.swift
 //  beeryMe
 //
 //  Created by George Jowitt on 22/08/2017.

extension MapVC: CLLocationManagerDelegate {
    
    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
            guard let latest = locations.first else { return }
            //getPubs(location: latest)
            networkCall(location: latest)
    }
    
    func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
    }

    func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
        if status == .authorizedAlways || status == .authorizedWhenInUse {
            locationManager?.startUpdatingLocation()

    var pubs: [Pub] = []
    let queryService = QueryService()
    
    
    var locationManager: CLLocationManager?
    @IBOutlet weak var mapView: MKMapView!
    var startLocation = CLLocation(latitude: 51.47281, longitude: -0.16145)
    let regionRadius: CLLocationDistance = 500
    
    override func viewDidLoad() {
        super.viewDidLoad()
     
        setUpMapView()
        setUpLocationManager()
        //
    }
    
    func setUpMapView() {
        mapView.delegate = self
    }
    
    func centreOnLocation(_ location: CLLocation) {
        let coordinateRegion = MKCoordinateRegionMakeWithDistance(location.coordinate,
        regionRadius, regionRadius)
        mapView.setRegion(coordinateRegion, animated: true)
        
        networkCall(location: location)
    }
    
    func setUpLocationManager() {
