F.SO4 F.SO4 - 1 year ago 140
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!

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download