Exemple #1
0
		public bool StartTracking ()
		{
			if (_manager != null && !_trackingStarted) {
				_startTime = DateTime.UtcNow;
				_currentLocation = new GPSCoordinate ();
				_manager.StartUpdatingLocation ();

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

				_trackingStarted = true;
				return true;
			}
			return false;
		}
Exemple #2
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;
		}
Exemple #3
0
 void RefreshCurrentLocation()
 {
     if (System.DateTime.Now > _lastRequest.AddSeconds(DEFAULT_TIMEOUT))
         _current = _provider.CurrentLocation;
 }