From 4f22423e612b0b26b2a2e88c5e98ff0a7bb24bc4 Mon Sep 17 00:00:00 2001 From: Yigal Omer Date: Wed, 26 Sep 2018 17:45:53 +0300 Subject: [PATCH] disable center button when location is not allowed --- Anyway/ViewController.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Anyway/ViewController.swift b/Anyway/ViewController.swift index 4e8f9f5..947c9f2 100644 --- a/Anyway/ViewController.swift +++ b/Anyway/ViewController.swift @@ -93,10 +93,8 @@ class ViewController: UIViewController, CLLocationManagerDelegate { } } - @IBAction func centerMyLocationButtonClicked(_ sender: Any) { - map.setUserTrackingMode(MKUserTrackingMode.follow, animated: true) - } - + + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) } @@ -118,6 +116,12 @@ class ViewController: UIViewController, CLLocationManagerDelegate { //MARK: - Logic + @IBAction func centerMyLocationButtonClicked(_ sender: Any) { + if isLocationMonitoringAuthorized() { + map.moveAndZoom(to: map.userLocation.coordinate) + } + } + var isMapCloseEnoughToFetchData: Bool { return btnFilter.isEnabled }