F.SO4 F.SO4 - 3 months ago 33x
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