2

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

4

1 回答 1

12

CLLocationCoordinate2D是 structlatitude并且longitude都定义为CLLocationDegreeswhich 本身是double.

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

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

您现在可以通过调用location.latitude和访问这些值location.longitude

于 2015-04-26T08:00:02.377 回答