0
我想在地图上显示代表用户位置的蓝点。如何在Google Maps iOS SDK上显示用户位置
我一直试图做这样的:
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" {
self.mapView.animateToLocation((object?.myLocation!!.coordinate)!)
self.mapView.animateToZoom(17)
}
}
但observeValueForKeyPath(keyPath: ofObject: change: context:)
不叫,我不明白为什么。
非常感谢!
和GMSMapView中的myLocation财产揭示了用户的位置点被绘制在那里(当myLocationEnabled为true)。 – lucianoenrico