据我所知,最大值和最小值是:
纬度: [-90, 90]
经度: [-180, 180]
CLLocation 仍然接受超出这些限制的值,例如:
[[CLLocation alloc] initWithLatitude:100.0 longitude:-200.0];
并且 CLLocation 的 distanceFromLocation:
函数仍然返回有效距离(尽管我们无法验证这一点,因为坐标超出了限制)。
为什么会这样?
我的想法如下:
1. 超出这些限制的值对应于外太空
2. 超出这些限制的值对应于其他尺寸
3. 超出这些限制的值将重新映射到 [-90, 90] 或 [-180, 180] 范围内的有效值。
最佳答案
纬度和经度是 CLLocationDegrees 的一种类型:
//From CLLocation.h
/*
* initWithLatitude:longitude:
*
* Discussion:
* Initialize with the specified latitude and longitude.
*/
- (id)initWithLatitude:(CLLocationDegrees)latitude
longitude:(CLLocationDegrees)longitude;
如果你进一步观察,其中是一种 double 类型:
//From CLLocation.h
/*
* CLLocationDegrees
*
* Discussion:
* Type used to represent a latitude or longitude coordinate in degrees under the WGS 84 reference
* frame. The degree can be positive (North and East) or negative (South and West).
*/
typedef double CLLocationDegrees;
what is the range of a double in Objective-C?
因此,我相信没有内置 checkin 为纬度和经度提供的值。
关于ios - CLLocation 接受大于或小于其最小值和最大值的经度和纬度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16681824/