gpt4 book ai didi

swift - 将 CLLocationCoordinate2D 转换为 double 或 int swift

转载 作者:可可西里 更新时间:2023-10-31 23:58:08 35 4
gpt4 key购买 nike

我如何将 CLLocationcoordiante 转换为 double 以便我可以对其进行运算并使用它们的大小比较坐标?在( swift 为 ios)

最佳答案

CLLocationCoordinate2Dlatitudelongitude 的结构,它们都定义为 CLLocationDegrees,它本身是 的类型别名>双

以下代码在代码中创建了一个位置,但它也可以由 MapKit 函数提供:

var location = CLLocationCoordinate2D(latitude: 10.30, longitude: 44.34)

您现在可以通过调用 location.latitudelocation.longitude 来访问这些值。

关于swift - 将 CLLocationCoordinate2D 转换为 double 或 int swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29875046/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com