示例#1
0
        public async void getLocate()
        {
            while (true)
            {
                if (_coordinates.Text.StartsWith("Cannot", StringComparison.Ordinal))
                {
                    _coordinates.Text   = "Calculating Location...";
                    _progressbar.Hidden = false;
                }

                locating = true;

                try
                {
                    var position = await locator.GetPositionAsync(29000);

                    string latitude  = Convert.ToDouble(position.Latitude).ToString("#.###");
                    string longitude = Convert.ToDouble(-position.Longitude).ToString("#.###");
                    string altitude  = (Convert.ToInt32((position.Altitude) * 3.28084)).ToString();

                    _coordinates.Text = latitude + "º N,  " + longitude + "º W" + Environment.NewLine + altitude + " ft Elevation";
                }
                catch
                {
                    _coordinates.Text = "Cannot Determine Location";
                }

                _progressbar.Hidden = true;
                locator.StopListening();
                locating = false;

                await Task.Delay(9000);
            }
        }
 public void StopTracking()
 {
     if (_geo.IsListening)
     {
         _geo.StopListening();
     }
 }
示例#3
0
        public void AddListener(EventHandler <PositionEventArgs> listener)
        {
            lock (_locker)
            {
                if (_locator == null)
                {
                    throw new Exception("Locator has not yet been bound to a platform-specific implementation.");
                }

                if (ListeningForChanges)
                {
                    _locator.StopListening();
                }

                PositionChanged += listener;

                _locator.StartListening(_minimumTimeHintMS, _desiredAccuracyMeters, true);

                SensusServiceHelper.Get().Logger.Log("GPS receiver is now listening for changes.", LoggingLevel.Normal, GetType());
            }
        }
示例#4
0
        public void StopTracking()
        {
            if (!IsTracking)
            {
                return;
            }
            CurrentLocation.IsEnabled    = false;
            CurrentLocation.IsResolved   = false;
            _geolocator.PositionError   -= OnListeningError;
            _geolocator.PositionChanged -= OnPositionChanged;
            _geolocator.StopListening();

            IsTracking = false;

            _geolocator = null;
        }
示例#5
0
        public void StopTrackingLocation()
        {
            geolocator.StopListening();

            TimeSpan totalRunTime = DateTimeOffset.Now - startTime;

            var newRun = new Run {
                RunDate                      = DateTime.Now,
                DistanceInMeters             = CurrentDistance,
                AveragePaceInMetersPerSecond = AveragePace,
                DurationInSeconds            = Convert.ToInt32(Math.Round(totalRunTime.TotalSeconds, 0)),
            };

            newRun.Create(totalPositionHistory);

            Init();
        }
 protected override void OnPause()
 {
     base.OnPause();
     _locator.StopListening();
 }