一旦用户的位置已经被迅速发现,使当前位置显示在地图上3
问题描述:
您好我正在尝试修复这个功能,直到swift 3完全正常,有人知道这个改变是什么吗?一旦用户的位置已经被迅速发现,使当前位置显示在地图上3
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if !didFindMyLocation {
let myLocation: CLLocation = change?[NSKeyValueChangeKey] as! CLLocation //Getting an error here Cannot convert value of type '(NSKeyValueChangeKey).Type' (aka 'NSKeyValueChangeKey.Type') to expected argument type 'DictionaryIndex<_, _>'
viewMap.camera = GMSCameraPosition.camera(withTarget: myLocation.coordinate, zoom: 10.0)
viewMap.settings.myLocationButton = true
didFindMyLocation = false
}
}
答
你应该提供适当的键象下面这样:
let myLocation: CLLocation = change?[NSKeyValueChangeKey.newKey] as! CLLocation