F.SO4 F.SO4 - 10 months ago 79
iOS Question

How to show user location on Google Maps iOS SDK

I want to present the blue dot on the map that represents the user's location.

I've tried to do it like that:

override func viewWillAppear(animated: Bool) {
self.mapView.addObserver(self, forKeyPath: "myLocation", options: NSKeyValueObservingOptions.New, context: nil)

deinit {
self.mapView.removeObserver(self, forKeyPath: "myLocation")

override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
if keyPath == "myLocation" {

observeValueForKeyPath(keyPath: ofObject: change: context:)
doesn't called and I can't understand why.

Thank you very much!


You can do this with following line of code. This will bring up the google's default blue dot on users current location.

self.mapView.myLocationEnabled = true