4

我目前正在使用位置管理器的区域功能。不幸的是,我无法收到任何小于 100m 的过境点的通知。我创建了半径为 20m / 50m 或 70m 的区域,但我总是只会在越过 100m 边界时收到通知。但我希望有一个更精细的半径 - 例如 20m 并且也会收到通知。如果我有一个大于 100m 的范围 - 例如 150m,那么一切都很好。在这种情况下,我一进入 150m 就会收到通知,正如我所期望的那样。

我尝试使用 LocationManager 上的“kCLLocationAccuracy”设置和 CLRegions 的创建,但两者似乎都没有任何效果。

这是我使用的代码:

- (void) initializeLocationManager
{
    // Check to ensure location services are enabled
    if(![CLLocationManager locationServicesEnabled]) {
        [self showAlertWithMessage:@"You need to enable location services to use this app."];
        return;
    }

    if(![CLLocationManager regionMonitoringAvailable]) {
        [self showAlertWithMessage:@"This app requires region monitoring features which are unavailable on this device."];
        return;
    }

    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    self.locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
}

- (void) setupGeoFence:(Station*)station
{ 
    CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake([station.gpsPosition.latitude doubleValue], [station.gpsPosition.longitude doubleValue]);
    CLRegion *geofence = [[CLRegion alloc] initCircularRegionWithCenter:centerCoordinate radius:[range doubleValue] identifier:station.name];  
    [self.locationManager startMonitoringForRegion:geofence desiredAccuracy:kCLLocationAccuracyBest];
}

有谁知道如何在更近的边界上接收通知?任何帮助都会受到高度评价。

谢谢哈姆托

4

1 回答 1

9

那样大小的区域是不可能的。位置事件主要由设备周围的 Wifi 触发。除非绝对必要,否则不会真正使用 GPS。所以50M以下的区域真的是垃圾拍摄。我已经与 CoreLocation 工程师讨论过这个问题(以及围绕区域监控的其他一些奇怪行为),并且由于对 Wifi 的依赖,不建议使用小尺寸。他们实际上推荐 150M,即使它没有记录。

如果您确实需要细粒度的位置更新,您可能需要实施自己的检查或启动 GPS 以获得非常准确的读数。这伴随着电池击中,因此您的里程可能会有所不同。祝你好运。

于 2013-07-22T18:20:09.887 回答