Example #1
0
        public bool UpdateLocation(int timeout)
        {
            bool result = false;

            if (_manager != null)
            {
                DateTime lastTime = DateTime.Now;
                while (lastTime.AddSeconds(timeout) > DateTime.Now)
                {
                    CLLocation location = _manager.Location;

                    if (location != null)
                    {
                        DateTime time = DateTime.SpecifyKind(location.Timestamp, DateTimeKind.Unspecified);
                        if (DateTime.UtcNow < time.AddMinutes(5))
                        {
                            _currentLocation = new GpsCoordinate(location.Coordinate.Latitude, location.Coordinate.Longitude, time);
                            result = true;
                            break;
                        }
                    }
                }
            }
            return result;
        }
Example #2
0
        private bool Start()
        {
            if (_manager != null && !_trackingStarted)
            {
                _currentLocation = new GpsCoordinate();

                if (new Version(UIDevice.CurrentDevice.SystemVersion).Major > 7)
                    _manager.RequestAlwaysAuthorization();

                _manager.StartUpdatingLocation();
                _trackingStarted = true;
                return true;
            }
            return false;
        }