2014-02-25 78 views
0

我已經爲geolocalisation一個應用程序,我檢索當前geoposition,但對應用程序的顯示速度很慢...geolocalisation很慢

構造:

 public TaskGeo() 
     { 
      InitializeComponent(); 
      _geolocator = new Geolocator(); 
      _geolocator.DesiredAccuracy = PositionAccuracy.High; 
      _geolocator.MovementThreshold = 100; 
      _geolocator.PositionChanged += _geolocator_PositionChanged; 
      _geolocator.StatusChanged += _geolocator_StatusChanged; 

      if (_geolocator.LocationStatus == PositionStatus.Disabled) 
       this.DisplayNeedGPS(); 
     } 

的代碼在應用程序中顯示:

void _geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) 
    { 
     // saving and display of the position 
     App.RootFrame.Dispatcher.BeginInvoke(() => 
     { 
      this._CurrentPosition = args.Position; 
      this.lblLon.Text = "Lon: " + this._CurrentPosition.Coordinate.Longitude; 
      this.lblLat.Text = "Lat: " + this._CurrentPosition.Coordinate.Latitude; 
      this.LocationChanged(this._CurrentPosition.Coordinate.Longitude, this._CurrentPosition.Coordinate.Latitude); 
     }); 
    } 

而對於查詢代碼:

private void LocationChanged(double lat, double lon) 
    { 
     ReverseGeocodeQuery rgq = new ReverseGeocodeQuery(); 
     rgq.GeoCoordinate = new GeoCoordinate(lat, lon); 
     rgq.QueryCompleted += rgq_QueryCompleted; 
     rgq.QueryAsync(); 
    } 

如何改善代碼以顯示更快的位置?提前致謝 !

回答

3

獲取這類信息基本上很慢。引用偉大的路易斯·C·K「它將進入太空,給它一秒鐘」。因爲您指定了PositionAccuracy.High,這意味着必須使用相對較慢的GPS找到該位置,而不是使用本地Wi-Fi或手機塔等更快速的後備方法。

您可以減少您對整體精度的要求,或者初始要求較低的準確度,然後在GPS信息可用時對其進行優化。第二種選擇更好。如果您查看地圖應用程序,他們通常會顯示您的位置,然後在獲取GPS鎖定後改進它。

+0

我認爲Stimms是對的。我們總是必須以速度來補償準確性。嘗試降低準確性。讓我們知道它是否越來越好。使用IP地址執行地理定位比GPS或wifi更快。 –