【问题标题】:How to convert CLLocationCoordinate2D latitude and longtitute to double?如何将 CLLocationCoordinate2D 纬度和经度转换为双倍?
【发布时间】:2017-04-29 15:17:21
【问题描述】:

如何在 Swift 3 中将CLLocationCoordinate2D 纬度和经度转换为Double

【问题讨论】:

  • 无需将坐标.纬度和经度转换为双精度值。纬度和经度已经只有双精度值。您将通过变量赋值,例如 let lati = coordinate.latitude, ..

标签: google-maps swift3 cllocation


【解决方案1】:

CLLocationCoordinate2Dlatitudelongitude 实例属性属于CLLocationDegrees 类型,这是typealiasDouble

所以你真的不需要做任何事情:

func printDouble(_ d: Double) { print(d) }

let coords = CLLocationCoordinate2D(latitude: 123.0, longitude: 456.0)
printDouble(coords.latitude) // Works just fine
printDouble(coords.longitude)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-01
    相关资源
    最近更新 更多