/// <summary> /// Retrieves the current location. /// </summary> /// <param name="desiredAccuracy">The desired accuracy.</param> /// <param name="maximumAge">The maximum acceptable age of cached location data.</param> /// <param name="timeout">The timeout.</param> /// <param name="locationResult">The current location.</param> public void GetPosition(LocationServiceAccuracy desiredAccuracy, TimeSpan maximumAge, TimeSpan timeout, Action <LocationServicePosition, Exception> locationResult) { var position = LastPosition; if (position != null && position.Timestamp.Add(maximumAge) > DateTimeOffset.Now) { locationResult(position.ToLocationServicePosition(), null); } else { new CurrentLocationHelper(timeout, locationResult).Start(desiredAccuracy.ToGeoPositionAccuracy()); } }
/// <summary> /// Starts the acquisition of data from the location service. /// </summary> /// <param name="desiredAccuracy">The desired accuracy.</param> public void Start(LocationServiceAccuracy desiredAccuracy) { Start(desiredAccuracy.ToGeoPositionAccuracy(), _movementThreshold); _timer = new DispatcherTimer() { Interval = new TimeSpan(_reportInterval) }; _timer.Tick += ReportTimerTick; if (_reportInterval != 0) { _timer.Start(); } }
/// <summary> /// Retrieves the current location. /// </summary> /// <param name="desiredAccuracy">The desired accuracy.</param> /// <param name="maximumAge">The maximum acceptable age of cached location data.</param> /// <param name="timeout">The timeout.</param> /// <param name="locationResult">The current location.</param> public void GetPosition(LocationServiceAccuracy desiredAccuracy, TimeSpan maximumAge, TimeSpan timeout, Action<LocationServicePosition, Exception> locationResult) { var position = LastPosition; if (position != null && position.Timestamp.Add(maximumAge) > DateTimeOffset.Now) { locationResult(position.ToLocationServicePosition(), null); } else { new CurrentLocationHelper(timeout, locationResult).Start(desiredAccuracy.ToGeoPositionAccuracy()); } }
/// <summary> /// Retrieves the current location. /// </summary> /// <param name="desiredAccuracy">The desired accuracy.</param> /// <param name="locationResult">The current location.</param> public void GetPosition(LocationServiceAccuracy desiredAccuracy, Action<LocationServicePosition, Exception> locationResult) { new CurrentLocationHelper(TimeSpan.FromSeconds(10), locationResult).Start(desiredAccuracy.ToGeoPositionAccuracy()); }
/// <summary> /// Retrieves the current location. /// </summary> /// <param name="desiredAccuracy">The desired accuracy.</param> /// <param name="locationResult">The current location.</param> public void GetPosition(LocationServiceAccuracy desiredAccuracy, Action <LocationServicePosition, Exception> locationResult) { new CurrentLocationHelper(TimeSpan.FromSeconds(10), locationResult).Start(desiredAccuracy.ToGeoPositionAccuracy()); }