0
我有地圖工具包視圖,當應用程序加載時,它會獲取用戶當前位置並對其進行跟蹤。然後它運行一個功能,專注於我也鏈接到一個按鈕的用戶位置,以便用戶可以瀏覽並聚焦到他們的位置範圍。當前位置跨度在地圖工具包視圖中變爲隨機數
在這個函數中,我將span設置爲0.01,但是當我打印span值時它的不同。當應用程序運行和重點的第一次,緯度跨度在0.00745918279325508
打印然後,當我打它運行完全相同的功能,對焦按鈕,拉特跨度在0.0102124663369167印刷及其明顯縮小
爲什麼在我已經將它設置爲0.01時執行此操作?這裏是我的代碼:
@IBAction func focusLocation(sender: UIButton)
{
snapLocation()
}
var locationManager: CLLocationManager!
override func viewDidLoad()
{
super.viewDidLoad()
if (CLLocationManager.locationServicesEnabled())
{
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
snapLocation()
}
}
func snapLocation()
{
let currentLocation = locationManager.location?.coordinate
let latitude:CLLocationDegrees = (currentLocation?.latitude)!
let longitude:CLLocationDegrees = (currentLocation?.longitude)!
let latDelta:CLLocationDegrees = 0.01
let lonDelta:CLLocationDegrees = 0.01
let span = MKCoordinateSpanMake(latDelta, lonDelta)
let location = CLLocationCoordinate2DMake(latitude, longitude)
let region = MKCoordinateRegionMake(location, span)
mapkitView.setRegion(region, animated: true)
}