我可以通过提供纬度和经度来初始化一个 CLLocation
对象,如下所示:
CLLocation *location = [[CLLocation alloc] initWithLatitude:-43.242534 longitude:-54.93662];
如何初始化一个 CLLocation
对象,不仅有纬度和经度,还有精度值?
最佳答案
根据苹果docs您可以使用以下功能:
double desired_horizontal_accuracy = 200.0 // in meters
double desired_vertical_accuracy = 200.0 // in meters
[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(-43.242534,-54.93662)
altitude:-1
horizontalAccuracy:desired_horizontal_accuracy
verticalAccuracy:desired_vertical_accuracy
timestamp:[NSDate date]]
在示例中,对于参数 altitude
和 timestamp
,我设置了与苹果文档所说的在 -initWithLatitude:longitude:
上使用的相同的默认值。
关于ios - 在 objective-c 中创建 CLLocation 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37886711/