I am making a single view application in Xcode, with Google Map SDK. I have followed instructions online and my application can successfully load the google map view. I have also enabled myLocation
, so that myLocation
button shows on the map view.
I understand that clicking the myLocation button will change the camera location automatically, but I'm wondering what I should do to use the data of myLocation
(say to add a marker or add a path node)?
I've tried directly accessing mapView.myLocation
, for example
let lat = mapView.myLocation?.coordinate.latitude
let long = mapView.myLocation?.coordinate.longitude
path.addCoordinate(CLLocationCoordinate2D(latitude: lat!, longitude: long!))
However, this will crash the applicaton and throw:
fatal error: unexpectedly found nil while unwrapping an Optional value
What does this error message mean and how should I resolve this?