当无法获得当前的LatLon时,重新启动GeoCoordinateWatcher的最佳做法是什么

时间:2012-08-21 08:58:34

标签: windows-phone-7

声明GeoCoordinateWatcher跟踪器。此跟踪器将在PageOnload事件上启动,如下所示。

我不知道如何创建一个条件,以便它显示:case GeoPositionStatus.NoData,所以我需要一些建议。我的目标是重新开始,直到获得当前的纬度和经度。

Q1)对于GeoPositionStatus.NoData案例,重新启动GeoCoordinateWatcher的最佳做法是什么?

在GeoPositionStatus.NoData

的情况下执行此操作

tracker.Stop();  tracker.Start();




   void tracker_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
   {
      switch (e.Status)
       {
            case GeoPositionStatus.Disabled:

            if (tracker.Permission == GeoPositionPermission.Denied)
             {
                 MessageBox.Show("The location Service on this device is off.Please read privacy.");
              }
            else
              {
                  MessageBox.Show("Location service is working but it can not get location data.");
               }
              break;

           case GeoPositionStatus.Initializing:

              // Code which needs to be initialized goes here
                break;

            case GeoPositionStatus.NoData:

               //MessageBox.Show("Location data is not available.");

               break;

               case GeoPositionStatus.Ready:
                    // Code which needs to be executed when location data is available goes here
                    break;
            }
        }

0 个答案:

没有答案