【发布时间】:2017-04-29 15:17:21
【问题描述】:
如何在 Swift 3 中将CLLocationCoordinate2D 纬度和经度转换为Double?
【问题讨论】:
-
无需将坐标.纬度和经度转换为双精度值。纬度和经度已经只有双精度值。您将通过变量赋值,例如 let lati = coordinate.latitude, ..
标签: google-maps swift3 cllocation
如何在 Swift 3 中将CLLocationCoordinate2D 纬度和经度转换为Double?
【问题讨论】:
标签: google-maps swift3 cllocation
CLLocationCoordinate2D 的latitude 和longitude 实例属性属于CLLocationDegrees 类型,这是typealias 的Double。
所以你真的不需要做任何事情:
func printDouble(_ d: Double) { print(d) }
let coords = CLLocationCoordinate2D(latitude: 123.0, longitude: 456.0)
printDouble(coords.latitude) // Works just fine
printDouble(coords.longitude)
【讨论】: