我想获取当前位置,但我得到一个错误.
这是我的视图控制器的片段.
- (void)viewDidLoad {
self.locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray<CLLocation *> *)locations {
// I would get the latest location here
// but this method never gets called
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error {
NSLog(@"didFailWithError: %@", error);
}
Run Code Online (Sandbox Code Playgroud)
我期待委托方法locationManager:didUpdateLocations:被调用,但只是locationManager:didFailWithError:被调用,并打印出来:
didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
Run Code Online (Sandbox Code Playgroud) 我需要一种比较两种方法的方法,CLLocationCoordinate2D但是当我尝试使用==它时,它是行不通的.请有人帮助我比较它们的最佳方法吗?
我想让它显示两个CLLocation坐标之间的距离.没有复杂的数学公式,有没有办法做到这一点?如果没有,你会怎么做公式?
CLLocationManager在iPhone模拟器上应该假冒库比蒂诺(不是吗?)但它没有,它失败了kCLErrorDomain Code=0.LocationManager的委托接收消息didFailWithError.实现此方法以记录错误,控制台输出以下内容:
Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
Run Code Online (Sandbox Code Playgroud)
当我遇到这个问题时,我正在研究一个真实的项目,但讨论我的代码是没有意义的,因为我从开发中心下载了"Locations"示例代码(iOS 4更新为2010-06-22)并且问题仍然存在.
当应用程序收到第一个位置更新时,该应用程序将启用"添加"按钮,以便用户可以跟踪其位置,但不执行任何操作.
我添加了一个(普通的)行didFailWithError来记录错误,如果有的话.我得到上述错误.
使用Xcode 3.2.2和目标3.1.3,我可以在运行较旧版本的"Locations"项目时获得固定位置(Cupertino).
有人可以帮忙吗?
谢谢.
我最近一直在研究基于位置的应用程序,并注意到CLLocation的一些奇怪的值.我经常得到horizontalAccuracy的1414和verticalAccuracy的-1.有什么迹象表明这是什么意思?据我所知,这些点往往非常准确.verticalAccuracy和horizontalAccuracy有什么区别?
我正在尝试使用Core Location,MapKit和Core Data框架保存位置并在地图上检索位置.
我所做的是我刚刚创建了名为POI的实体并添加了诸如纬度(双重类型),经度(双重类型)等属性.
简单地说,我的应用程序使用两个NSNumber保存POI.(lat和long)但我觉得必须有一个更聪明的方法来存储CLLocation.
干杯.
CLLocation.h中列出了以下内容,但根据我的经验,它们是欺骗性的名称 - 可能最初被认为有两个目的,1.测试返回位置的准确性,以及2.设置位置管理器的工作难度,具体是什么启用(gps(多少个卫星频道),wifi工作有多难,三角测量等.
extern const CLLocationAccuracy kCLLocationAccuracyBestForNavigation; // (raw value: -2)
extern const CLLocationAccuracy kCLLocationAccuracyBest; // (raw value: -1)
extern const CLLocationAccuracy kCLLocationAccuracyNearestTenMeters; // (raw value: 10)
extern const CLLocationAccuracy kCLLocationAccuracyHundredMeters; // (raw value: 100)
extern const CLLocationAccuracy kCLLocationAccuracyKilometer; // (raw value: 1000)
extern const CLLocationAccuracy kCLLocationAccuracyThreeKilometers; // (raw value: 3000)
Run Code Online (Sandbox Code Playgroud)
我很想看看CLLocation.m,但由于这种情况不太可能很快发生 - 任何人都有任何现场测试显示他们认为这些不同模式正在发生的事情.
即,kCLLocationAccuracyBest = 10卫星(频道/中继?),100%电源到wifi等.
我有点猜测这里的稻草 - 我认为这是苹果应该提供的信息类型 -
我真正想知道的是,与kCLLocationAccuracyThreeKilometers电池电量相关的实际情况是gps开启了吗?1坐在后备箱?启用wifi?计时器上的wifi?谁知道?我知道我想
我正在尝试获取当前位置,但是didUpdateLocations中的断点永远不会被调用.
的LocationManager:
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager setDesiredAccuracy:kCLDistanceFilterNone];
[locationManager startUpdatingLocation];
Run Code Online (Sandbox Code Playgroud)
代表方法:
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations;
Run Code Online (Sandbox Code Playgroud)
我确认了位置服务并启用并授权.
为什么没有像它应该调用locationManager委托方法?
谢谢,迈克
我有一个数组allCollections,它包含用户通过我的iOS应用程序记录的以编程方式创建的CLLocations数组.allCollections中的每个子数组都包含所有行程中的所有位置点.
我从allCollections中的数组中的CLLocations中绘制MKPolylines来表示MKMapView上的那些行程.我的问题是:将折线添加到地图中,我将如何以编程方式缩放和居中地图以显示所有这些?