2017-04-09 16 views
1

我正在研究一個項目,我需要存儲設備的經緯度。但是當設備在其位置改變5或10米時,我需要將它們存儲起來。我搜索了大約2天,但找不到任何幫助我的東西。所以我想出了intuit/LocationManager庫。我可以成功獲得這個圖書館的單一位置。但此方法內的塊只執行一次,無論設備的位置改變了多少次如果設備位置改變了5或10米,如何獲得通知?

我已經用真實設備模擬器進行了測試。在模擬器上,我手動更改這樣的位置:simulate location image

但我沒有得到顯著變化更新。

以下是我迄今所做的:

- (void)startMonitoringSignificantLocationChanges 
{ 
    __weak __typeof(self) weakSelf = self; 
    INTULocationManager *locMgr = [INTULocationManager sharedInstance]; 
    self.locationRequestID = [locMgr subscribeToSignificantLocationChangesWithBlock:^(CLLocation *currentLocation, INTULocationAccuracy achievedAccuracy, INTULocationStatus status) { 
     __typeof(weakSelf) strongSelf = weakSelf; 

     _lastLocation = currentLocation; 

     if (status == INTULocationStatusSuccess) { 
      _significantChangeCount++; 

      // A new updated location is available in currentLocation, and achievedAccuracy indicates how accurate this particular location is 
      strongSelf.changedLatitude.text = [NSString stringWithFormat:@"%f", currentLocation.coordinate.latitude]; 
      strongSelf.changedLongitude.text = [NSString stringWithFormat:@"%f", currentLocation.coordinate.longitude]; 
      strongSelf.changedTime.text = [self getLocaleDateString:currentLocation.timestamp]; 
      if (_significantChangeCount > 0) { 
       strongSelf.changedStatus.text = @"Significant change"; 
      } else { 
       strongSelf.changedStatus.text = @"Monitor started"; 
      } 
     } 
     else { 
      // An error occurred 
      strongSelf.errorLabel.text = [strongSelf getLocationErrorDescription:status]; 
     } 
    }]; 
} 

任何幫助,將不勝感激。或者任何其他方式來完成這項任務?

+0

我無法在帖子中添加超過2個鏈接,因此添加了評論:***我已經上傳了我的整個測試項目[此處](https://drive.google.com/file/d/0Bzxb70Gwq7HWMkVDNkp2WGVUcTg /視圖?USP =共享)***。任何幫助? – Bixby

回答

0

的5至10米運動不能算作中位置的「顯著」的變化:

應用程序能夠儘快期待一個通知,該設備從之前通知移動500米以上。它不應該比每五分鐘更頻繁地發出通知。

source

如果你需要監控的5-10米尺度的變化,你將需要使用不同的方法。

+0

你能告訴我其他不同的方法嗎?我是新的位置服務。 – Bixby

相關問題