高度数据类型
The data type of altitude
这可能是一个很奇怪的问题,我正在尝试找出高度的数据类型,但我不确定是否应该这样称呼它。但是任何建议都会非常有帮助。所以我需要帮助的代码位在这里:
var latitude:CLLocationDegrees = 0
var longitude:CLLocationDegrees = 0
var speed:CLLocationSpeed = 0
var course:CLLocationDirection = 0
var altitude:CLLocation
如您所见,var altitude:CLLocation
未完全声明,因为我不确定它的数据类型。我应该写些什么来完成这份声明?只是为了给你一些上下文,这里是完整的代码(我认为没有必要阅读所有代码,但它就在这里):
//
// ViewController.swift
// Map Demo My Try
//
// Created by Jae Hyun Kim on 8/14/15.
// Copyright © 2015 Jae Hyun Kim. All rights reserved.
//
import UIKit
import MapKit
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
var locationManager = CLLocationManager()
var latitude:CLLocationDegrees = 0
var longitude:CLLocationDegrees = 0
var speed:CLLocationSpeed = 0
var course:CLLocationDirection = 0
var altitude:CLLocation
@IBOutlet weak var longitudeLabel: UILabel!
@IBOutlet weak var latitudeLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print(locations)
let userLocations: CLLocation = locations[0]
latitude = userLocations.coordinate.latitude
longitude = userLocations.coordinate.longitude
let speed = userLocations.speed
}
@IBAction func getInformation(sender: AnyObject) {
longitudeLabel.text = String(latitude)
latitudeLabel.text = String(longitude)
}
}
如有任何帮助,我们将不胜感激!
高度的类型是CLLocationDistance
(如CLLocation Reference中所述)
CLLocationDistance
是 Double
的类型别名。
这可能是一个很奇怪的问题,我正在尝试找出高度的数据类型,但我不确定是否应该这样称呼它。但是任何建议都会非常有帮助。所以我需要帮助的代码位在这里:
var latitude:CLLocationDegrees = 0
var longitude:CLLocationDegrees = 0
var speed:CLLocationSpeed = 0
var course:CLLocationDirection = 0
var altitude:CLLocation
如您所见,var altitude:CLLocation
未完全声明,因为我不确定它的数据类型。我应该写些什么来完成这份声明?只是为了给你一些上下文,这里是完整的代码(我认为没有必要阅读所有代码,但它就在这里):
//
// ViewController.swift
// Map Demo My Try
//
// Created by Jae Hyun Kim on 8/14/15.
// Copyright © 2015 Jae Hyun Kim. All rights reserved.
//
import UIKit
import MapKit
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
var locationManager = CLLocationManager()
var latitude:CLLocationDegrees = 0
var longitude:CLLocationDegrees = 0
var speed:CLLocationSpeed = 0
var course:CLLocationDirection = 0
var altitude:CLLocation
@IBOutlet weak var longitudeLabel: UILabel!
@IBOutlet weak var latitudeLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print(locations)
let userLocations: CLLocation = locations[0]
latitude = userLocations.coordinate.latitude
longitude = userLocations.coordinate.longitude
let speed = userLocations.speed
}
@IBAction func getInformation(sender: AnyObject) {
longitudeLabel.text = String(latitude)
latitudeLabel.text = String(longitude)
}
}
如有任何帮助,我们将不胜感激!
高度的类型是CLLocationDistance
(如CLLocation Reference中所述)
CLLocationDistance
是 Double
的类型别名。