Я пытаюсь увеличить пользователя, когда он запускает приложение, но я не могу понять, как это сделать. Я попробовал следующий вариант, который я нашел на stackoverflow, но он не хочет работать. Я не получаю никакой ошибки или чего-либо еще. Вы можете мне помочь?
Мой код:
class ViewController: UIViewController, CLLocationManagerDelegate {
private let locationManager = CLLocationManager()
lazy var mapView = GMSMapView()
override func viewDidLoad() {
super.viewDidLoad()
// Google maps api, camera set
let camera = GMSCameraPosition.camera(withLatitude: 47.095655, longitude: 19.281834, zoom: 1)
mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView.isMyLocationEnabled = true
mapView.settings.myLocationButton = true
view = mapView
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
//self.viewMap.addSubview(mapView)
//Adatbázis adatok lekérése, táblába rendezése, markerek lerakása
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
// 3
guard status == .authorizedWhenInUse else {
return
}
// 4
locationManager.startUpdatingLocation()
//5
mapView.isMyLocationEnabled = true
mapView.settings.myLocationButton = true
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let location = locations.first else {
return
}
// 7
mapView.camera = GMSCameraPosition(target: location.coordinate, zoom: 15, bearing: 0, viewingAngle: 0)
// 8
locationManager.stopUpdatingLocation()
}
}