I am attempting to display myLocation
in a GMSMapView
. Here is the code I have so far:
class ViewController: UIViewController {
// MARK: Properties
@IBOutlet weak var mapView: GMSMapView!
let locationManager = CLLocationManager()
let stdZoom: Float = 12
override func viewDidLoad() {
super.viewDidLoad()
self.locationManager.requestWhenInUseAuthorization()
mapView.myLocationEnabled = true
if let myLocation = mapView.myLocation {
print("my location enabled");
let update = GMSCameraUpdate.setTarget(myLocation.coordinate, zoom: stdZoom)
mapView.moveCamera(update)
} else {
print("my location could not be enabled")
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
I followed the advice of the question here to make the CLLocationManager
a class variable, and I set NSLocationWhenInUseUsageDescription
to a String in my Info.plist file in Xcode, but the prompt to allow location services is never shown in the simulator and I am getting the following console output:
2015-11-14 19:17:14.752 ios-demo[34759:569776] Simulator user has requested new graphics quality: 100
my location could not be enabled
2015-11-14 19:17:15.838 ios-demo[34759:569776] Google Maps SDK for iOS version: 1.10.21020.0
Can someone point out what I am missing?