标签: cllocation

CLLocation - 在另一个位置找到磁偏角/偏差

我知道如何找到我手机当前所在位置的真实航向/磁航向,但是有可能找到远程位置的磁偏差/磁偏角吗?

我想做的是能够将一个销钉放在地图上的某个位置,并从该点找到具有磁性变化的真实轴承和轴承.

谢谢!

iphone objective-c cllocation ios

7
推荐指数
2
解决办法
1132
查看次数

iPhone 3.0指南针:如何获得标题?

我对Objective-C比较陌生,对它还不太了解,所以我为这可能是一个非常业余的问题道歉.

我正在尝试从CLHeading和CLLocationDirection获取磁路.但是我得到这行代码的编译错误:

locationLabel.text = [[[location course] magneticHeading] stringValue];
Run Code Online (Sandbox Code Playgroud)

错误是:

warning: invalid receiver type 'CLLocationDirection'  
error: cannot convert to a pointer type
Run Code Online (Sandbox Code Playgroud)

我真的不明白我在这里做错了什么.请帮忙!

iphone cllocation

6
推荐指数
1
解决办法
1万
查看次数

核心位置区域监控

有谁知道使用这个的任何知识:

- (void) startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy

我正在尝试将它实现到我的项目中,但是:

- (void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region

永远不会被称为?

有没有人有任何示例代码或知道为什么会发生这种情况?

我的代码如下.我在自己的LocationManager类中创建了一个这样的方法:

 - (void) locationManagerStartMonitoringRegion:(CLRegion *)region withAccuracy:(CLLocationAccuracy)accuracy {
    NSLog(@"Start Monitoring");
    [locationManager startMonitoringForRegion:region desiredAccuracy:accuracy];
    NSLog(@"Monitored Regions: %i", [[locationManager monitoredRegions] count]);
}
Run Code Online (Sandbox Code Playgroud)

然后我这样称呼它:

CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(51.116261, -0.853758);     
CLRegion *grRegion = [[CLRegion alloc] initCircularRegionWithCenter:coordinates radius:150 identifier:[NSString stringWithFormat:@"grRegion%i", value]];

[locationManager locationManagerStartMonitoringRegion:grRegion withAccuracy:kCLLocationAccuracyBest];
Run Code Online (Sandbox Code Playgroud)

我得到NSLog的:

2011-01-30 19:52:26.409 TestingLocation [10858:307]开始监控

2011-01-30 19:52:27.103 TestingLocation [10858:307]受监控区域:

但是从来没有得到过NSLog:

 - (void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region     {
    NSLog(@"Entered Region");
}
Run Code Online (Sandbox Code Playgroud)

要么

 - (void) locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c cllocationmanager cllocation ios4

6
推荐指数
1
解决办法
9085
查看次数

需要归档CLLocation数据

我有一个CLLocation数据库,我想存档.该NSUserDefaults系统应该使用吗?否则,如何最好地存档CLLocation数据?

iphone nsuserdefaults nskeyedarchiver cllocation

6
推荐指数
2
解决办法
5526
查看次数

CLGeocoder反向地理编码失败,错误域= NSURLErrorDomain Code = -1000 -

使用CLLocation对象(内容例如纬度= 48.196169,经度= 11.620237),我尝试获取当前的城市和国家:

if(!geocoder) {
    geocoder = [[CLGeocoder alloc] init];
}

if (geocoder.geocoding) [geocoder cancelGeocode];
    [geocoder reverseGeocodeLocation:lo completionHandler:^(NSArray *placemarks, NSError *error) {
    if(devMode) {
        NSLog(@"Found placemarks: %@, error: %@", placemarks, error);
    }

    if (error == nil && [placemarks count] > 0) {
        // MY CODE - here placemarks is always (null)
    } else {
        if(devMode)
            NSLog(@"%@", error.debugDescription);
    }
}];
Run Code Online (Sandbox Code Playgroud)

大多数情况下,这很有效.但在极少数情况下,我只是得到错误:

PBRequester失败,错误错误域= NSURLErrorDomain代码= -1000"UngültigeURL"UserInfo = 0x16f5ff30 {NSUnderlyingError = 0x16f57810"UngültigeURL",NSLocalizedDescription =UngültigeURL}

找到地标:(null),错误:错误Domain = kCLErrorDomain Code = 2"操作无法完成.(kCLErrorDomain error 2.)"

我完全不知道为什么会这样.

cllocation clgeocoder ios7 xcode5

6
推荐指数
1
解决办法
2338
查看次数

在Swift中将GPS坐标转换为城市名称/地址

我有一个纬度/经度位置,我想转换为Swift中的位置名称String.做这个的最好方式是什么?我相信最好使用reverseGeocodeLocation函数,但不完全确定如何使用.这是我到目前为止:

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
    if (locationFixAchieved == false) {
        locationFixAchieved = true
        var locationArray = locations as NSArray
        var locationObj = locationArray.lastObject as CLLocation
        var coord = locationObj.coordinate
        var latitude = coord.latitude
        var longitude = coord.longitude

        getCurrentWeatherData("\(longitude)", latitude: "\(latitude)")
        reverseGeocodeLocation(location:coord, completionHandler: { (<#[AnyObject]!#>, <#NSError!#>) -> Void in
            <#code#>
        })

    }
}

func reverseGeocodeLocation(location: CLLocation!, completionHandler: CLGeocodeCompletionHandler!){

}
Run Code Online (Sandbox Code Playgroud)

gps cllocation clgeocoder cllocationcoordinate2d swift

6
推荐指数
2
解决办法
2万
查看次数

在CoreData中保存Swift CLLocation

我正在尝试CLLocation在Core Data中保存数据.我的属性设置为可转换对象.

一些示例代码表明可以使用此objc转换为a来保存位置数据NSValue.

CLLocationCoordinate2D myLocation;
NSValue *locationValue = [NSValue valueWithBytes:&myLocation objCType:@encode(CLLocationCoordinate2D)]
// then put locationValue into storage - maybe an ObjC collection class or core data etc.
Run Code Online (Sandbox Code Playgroud)

从数据存储中检索对象应该可以使用此范例.

CLLocationCoordinate2D myLocation;
NSValue *locationValue = // restored from your database or retrieved from your collection class
[locationValue getValue:&myLocation];
Run Code Online (Sandbox Code Playgroud)

我试图推断这个想法并将整个CLLocation对象捕获到NSValue存储中CoreData,目标CLLocation是稍后从商店中恢复对象.

在测试各种方法时,我发现在尝试CLLocation从Core Data Store中解包对象时返回了nil .我CLLocation使用以下内容将对象放入商店:

//verified that I have a good CLLocation here
newManagedObject.setValue(location as CLLocation, forKey: "location") …
Run Code Online (Sandbox Code Playgroud)

core-data cllocation nsvalue swift

6
推荐指数
2
解决办法
4530
查看次数

如何在 RxSwift 中使用 CLLocation 扩展

我想用CLLocationManagerRxSwift
https://github.com/ReactiveX/RxSwift/issues/413
但我发现CLLocationManager扩展感动得RxExample
(这里提到https://github.com/ReactiveX/RxSwift/issues/900)。

我的问题是:如何使用该代码?当我输入RxSwiftRxCocoa我没有获得如locationManager.rx.didUpdateLocations。我应该怎么做才能使用CoreLocationwith RxSwift

我正在使用 Xcode 8、Swift 3。

在此先感谢您的帮助!

更新

我发现,这是建议,现在我们必须只复制和粘贴CLLocationManager从分机RxExample(详见这里提交该意见)。

cllocation ios rx-swift swift3

6
推荐指数
1
解决办法
2412
查看次数

位置管理员为旧位置提供新的时间戳

我在iPhone应用程序中遇到以下问题:

我定期启用位置管理器,我等待多个位置更新.收到新位置后,我会检查新位置的时间戳属性,以确定它是否是旧位置:

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation {

    numberOfUpdatesInInterval++;
    NSLog(@"%d;%f;%f;%.0f;%@;%@;%@",
                              numberOfUpdatesInInterval,
                              newLocation.coordinate.latitude,
                              newLocation.coordinate.longitude,
                              newLocation.horizontalAccuracy,
                              newLocation.timestamp,
                              [self getCurrentDateAsString],
                              newLocation);
}
Run Code Online (Sandbox Code Playgroud)

我现在遇到的问题是我收到了新的位置,其中时间戳是新的,但坐标仍然是我之前收到的旧位置.当我以120km/h的速度驾驶我的汽车时,我测试了这个,多次接收相同的坐标但是时间戳不同.我在iOS 4和5中遇到了同样的问题.

这怎么可能?或者我该如何处理这个问题?

cllocationmanager cllocation ios

5
推荐指数
1
解决办法
1424
查看次数

iBeacon在前景中使用静态库

我已经创建了一个框架,负责注册CLBeaconRegions,并在范围内时,对CLBeacons进行测距,然后发送UILocalNotification.当我使用实际的类编译应用程序时,它应该工作,但是当我在胖静态库中编译应用程序时,它不会.

框架的作用:1.CLBeaconRegion的EnterRegion事件2.开始测距3.范围信标4.提供UILocalNotification

在具有实际类的应用程序中测试它时,它在前台和后台都有效.

在具有胖库的应用程序中测试时,它在后台运行,有时仅在前台运行.

知道这可能是什么问题吗?

static-libraries cllocation ios ibeacon

5
推荐指数
0
解决办法
100
查看次数