【发布时间】:2013-07-22 14:37:06
【问题描述】:
我目前正在使用位置管理器的区域功能。 不幸的是,我无法收到任何小于 100m 的过境点的通知。 我创建了半径为 20m / 50m 或 70m 的区域,但我总是只会在越过 100m 边界时收到通知。 但我想有一个更精细的半径 - 例如20m 并收到通知。如果我有一个大于 100m 的范围,一切都很好 - 例如 150米。在这种情况下,我一进入 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];
}
有人知道如何在更近的边界上接收通知吗?任何帮助都将受到高度评价。
谢谢 火腿
【问题讨论】:
标签: ios objective-c locationmanager clregion