2014-01-29 32 views
1

我試圖讓一個應用程序,不斷抓取位置的Windows Phone 8如何實現連續和精確的Windows 8米手機的GPS跟蹤

下面的代碼是用來獲取位置。

   geolocator = new Geolocator(); 
       geolocator.DesiredAccuracyInMeters = 30; 
       geolocator.ReportInterval = 15000; 
       geolocator.StatusChanged += geolocator_StatusChanged; 
       geolocator.PositionChanged += geolocator_PositionChanged; 

當gps正常進行時,一切正常。

但一旦GPS位置不availabile的Geolocator停止位置抓取。(這是當設備返回到GPS領域的geolocator_PositionChanged不叫)

我試圖創造一個新的geolocator對象geolocator_StatusChanged()this blog (geoposition advanced tracking scenarios for windows phone 8)

case PositionStatus.NoData: 
       geolocator = new Geolocator(); 
       geolocator.DesiredAccuracyInMeters = 30; 
       geolocator.ReportInterval = 15000; 
       geolocator.StatusChanged += geolocator_StatusChanged; 
       geolocator.PositionChanged += geolocator_PositionChanged; 

       status = "no data"; 
       break; 

但是這也沒有奏效。請指導我如何確保gps數據的持續可用性?

另一點值得注意的是,一旦gps信號源變成了Cellular,它永遠不會再使用Satalite作爲gps信號源(蜂窩信號源返回最不準確的gps值)。那麼我如何在Windows Phone 8中指定gps源代碼呢?

測試設備上完成的:諾基亞Lumia 520

+0

設置DesiredAccuracy屬性爲高才能使用GPS源 – anderZubi

回答

1

我有,我在的Lumia 520測試了一個完全工作的Windows Phone客戶端的位置,請對其進行測試,並讓我知道你在想什麼:

https://github.com/nickfox/GpsTracker/tree/master/phoneClients/windowsPhone

您不應該關心位置源和精度。如果一個來源符合您的要求的準確度(無論是gps,wifi還是cell),誰會關心它的來源。測試你的位置,以確保它符合您的需要精度:

if (args.Position.Coordinate.Accuracy < 100.0) { 
// do something with location 
} 
+0

感謝,我會檢查。我可以看到你的實現唯一的區別是你使用一個靜態geolocator對象。這有什麼重要嗎? –

+0

我假設你指的是我分配給App.Geolocator = new Geolocator()的那一行。我只是按照我看到的所有樣本做到這一點。通過分配給應用程序的App.Geolocator對象。 – nickfox