Тема 1: Неустранимая ошибка: неожиданно обнаружено ноль при неявном развертывании необязательного значения — MapView.isMIOS

Программируем под IOS
Anonymous
Тема 1: Неустранимая ошибка: неожиданно обнаружено ноль при неявном развертывании необязательного значения — MapView.isM

Сообщение Anonymous »

Код: Выделить всё

self.MapView.isMyLocationEnabled = true
gives the following error. How do I fix it?

Код: Выделить всё

import GoogleMaps

class ViewController: UIViewController,CLLocationManagerDelegate {

//Outlets
@IBOutlet var MapView: GMSMapView!

//Variables
var locationManager = CLLocationManager()

override func viewDidLoad() {
super.viewDidLoad()

initializeTheLocationManager()
self.MapView.isMyLocationEnabled = true
}

func initializeTheLocationManager() {
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {

var location = locationManager.location?.coordinate

cameraMoveToLocation(toLocation: location)

}

func cameraMoveToLocation(toLocation: CLLocationCoordinate2D?) {
if toLocation != nil {
MapView.camera = GMSCameraPosition.camera(withTarget: toLocation!, zoom: 15)
}
}

}
Вот как выглядит раскадровка. Я новичок в Swift и хочу видеть свое текущее местоположение на Картах Google через Swift. Что мне следует сделать по-другому?
Изображение

Изображение


Подробнее здесь: https://stackoverflow.com/questions/782 ... ing-an-opt

Вернуться в «IOS»