iOS 模拟器中的 CLLocationManager 问题
我尝试在地图上显示一个位置,这里是代码:
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager.location initWithLatitude:latitude longitude: longitude];
NSLog(@"%f", [selectedBuilding.latitude doubleValue]);
[locationManager startUpdatingLocation];
但是,无论我提供什么坐标,蓝点总是位于加利福尼亚州,这似乎是默认行为,我还需要做什么吗?谢谢。
I try to show a location on the map, here is the code:
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager.location initWithLatitude:latitude longitude: longitude];
NSLog(@"%f", [selectedBuilding.latitude doubleValue]);
[locationManager startUpdatingLocation];
However, no matter what coordinates I provide, the blue dot always locates in California which seems the default behaviour, is there anything additional I need to do? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在模拟器中CLLocationManager始终位于Apple总部。它来自 CLLocation 类参考:
坐标
地理坐标信息。 (只读)
@property(readonly, nonatomic) CLLocationCooperative2D 坐标
讨论
在模拟器中运行时,Core Location 会为此属性分配一组固定的坐标值。您必须在基于 iPhone OS 的设备上运行应用程序才能获取真实位置值。
可用性
适用于 iPhone OS 2.0 及更高版本。
声明于
CLLocation.h
In simulator CLLocationManager is always in headquarters of Apple. It's from CLLocation Class reference:
coordinate
The geographical coordinate information. (read-only)
@property(readonly, nonatomic) CLLocationCoordinate2D coordinate
Discussion
When running in the simulator, Core Location assigns a fixed set of coordinate values to this property. You must run your application on an iPhone OS–based device to get real location values.
Availability
Available in iPhone OS 2.0 and later.
Declared In
CLLocation.h