2013-07-22 45 views
4

我目前正在使用位置管理器的region-feature。 不幸的是,我無法獲得任何小於100米的邊界通道的通知。 我創建了半徑爲20米/ 50米或70米的地區,只要我穿過100米邊界,我總是隻收到通知。 但我想有一個更好的半徑 - 例如20米,也收到通知。如果我有一個大於100米的距離,一切都很好,例如 150m。在這種情況下,只要我按照我的預期輸入150米就會收到通知。iOS的CLRegion功能的最小半徑LocatinManager

我試着在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]; 
} 

有沒有人有一個想法如何得到一個更接近邊界的通知?任何幫助將高度appriciated。

感謝 Hamtho

回答

8

在這個大小的區域僅僅是不是真的有可能。位置事件主要由設備周圍的Wifi觸發。除非絕對必要,GPS並不真正使用。所以50M以下的地區真的是垃圾拍攝。我已經與CoreLocation工程師討論過這個問題(還有一些其他有關區域監控的奇怪行爲),並且由於依賴於Wifi,所以建議不要使用小尺寸。他們實際上推薦150M,即使它沒有記錄。

如果您確實需要細粒度的位置更新,您可能需要執行自己的檢查或啓動GPS以獲得非常準確的讀數。這隨着電池的命中,所以你的里程可能會有所不同。祝你好運。

+0

150米的建議是否適用於iOS 5-7? – Pochi

+1

是的。我通常推薦100M以獲得最佳效果,但100-150之間的任何值都可以使用。 –

+0

謝謝,生病做了一些測試。 – Pochi