public void Start(bool fine = false) { if (isStarted) { return; } isStarted = true; if (fine) { watcher.Start(new MvxLocationOptions { Accuracy = MvxLocationAccuracy.Fine, TrackingMode = MvxLocationTrackingMode.Foreground, TimeBetweenUpdates = TimeSpan.FromSeconds(5), MovementThresholdInM = 0 }, OnLocation, OnError); } else { watcher.Start(new MvxLocationOptions { Accuracy = MvxLocationAccuracy.Coarse, TrackingMode = MvxLocationTrackingMode.Foreground, TimeBetweenUpdates = TimeSpan.FromSeconds(30), MovementThresholdInM = 0 }, OnLocation, OnError); } }
public void Init() { if (!locationWatcher.Started) { locationWatcher.Start( new MvxLocationOptions { Accuracy = MvxLocationAccuracy.Coarse }, loc => { UserLocation = loc; const double tolerance = 0.001; if (Math.Abs(loc.Coordinates.Latitude) > tolerance && Math.Abs(loc.Coordinates.Longitude) > tolerance) { locationWatcher.Stop(); } }, error => { }); } // defaults userAge = 0; userId = string.Empty; userGender = Gender.Unknown; userLocation = new MvxGeoLocation { Coordinates = new MvxCoordinates { Latitude = 0, Longitude = 0, Accuracy = 0 } }; }
public void StartGetCurrentLocation(MvxLocationOptions options, Action <MvxGeoLocation> locationHandler, Action <MvxLocationError> errorHandler) { if (_locationWatcher != null) { _locationWatcher.Start(options ?? _locationOptions, locationHandler, errorHandler); } }
public LocationService(IMvxLocationWatcher watcher) { StatusMessage = "Current location is being resolved..."; _watcher = watcher; _watcher.Start(new MvxLocationOptions() { TimeBetweenUpdates = new TimeSpan(0, 0, 1), Accuracy = MvxLocationAccuracy.Fine }, OnLocation, OnError); }
public GpsService(IMvxLocationWatcher locationWatcher) { _locationWatcher = locationWatcher; if (!_locationWatcher.Started) { _locationWatcher.Start(new MvxLocationOptions(), OnSuccess, OnError); } }
public LocationService(IMvxLocationWatcher watcher, IMvxMessenger messenger) { _watcher = watcher; _messenger = messenger; _watcher.Start(new MvxLocationOptions() { Accuracy = MvxLocationAccuracy.Fine, TrackingMode = MvxLocationTrackingMode.Background }, OnLocation, OnError); }
//Init // public WeatherPagedViewModel(WeatherPageModel model, IMvxLocationWatcher watcher, IMvxMessenger massager) { _massager = massager; _token = _massager.Subscribe <CitiesMassage>(OnUpdateCities); _watcher = watcher; _watcher.Start(new MvxLocationOptions(), locationEventHandleAction, errorEventHandleAction); _model = model; this.InitViewModels(); }
public LocationService(IMvxLocationWatcher watcher) { StatusMessage = "Current location is being resolved..."; _watcher = watcher; _watcher.Start(new MvxLocationOptions() { TimeBetweenUpdates = new TimeSpan(0, 0, 1), Accuracy = MvxLocationAccuracy.Fine }, OnLocation, OnError); }
public void StartWatching() { if (!_watcher.Started) { _watcher.Start(new MvxLocationOptions { TimeBetweenUpdates = Constants.TimeBetweenUpdates, TrackingMode = MvxLocationTrackingMode.Background }, Success, Error); } Debug.WriteLine("Start watching"); }
public FirstViewModel(IMvxLocationWatcher locationWatcher) { this.locationWatcher = locationWatcher; Permission = "not specified"; Location = "zero"; locationWatcher.OnPermissionChanged += OnPermissionChanged; locationWatcher.Start(new MvxLocationOptions(), OnLocationUpdated, OnLocationError); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.map_screen); _locationWatcher = Mvx.Resolve <IMvxLocationWatcher>(); var options = new MvxLocationOptions(); _locationWatcher.Start(options, OnLocationFound, OnLocationNotFound); }
//private readonly MvxMessenger _messenger; public LocationService(IMvxLocationWatcher watcher, IMvxMessenger messenger) { _watcher = watcher; _messenger = messenger; var options = new MvxLocationOptions { MovementThresholdInM = 2500 }; _watcher.Start(options, OnLocation, OnError); }
public async void Start() { await EnsurePermissionExists(); _watcher.Start(new MvxLocationOptions { Accuracy = MvxLocationAccuracy.Fine, TimeBetweenUpdates = TimeSpan.FromSeconds(1), MovementThresholdInM = 1, TrackingMode = MvxLocationTrackingMode.Foreground }, OnLocation, OnError); }
public FirstViewModel(IMvxLocationWatcher locationWatcher) { _locationWatcher = locationWatcher; _locationWatcher.Start(new MvxLocationOptions { Accuracy = MvxLocationAccuracy.Fine }, OnLocation, OnError); _lat = _locationWatcher.CurrentLocation.Coordinates.Latitude; _lng = _locationWatcher.CurrentLocation.Coordinates.Longitude; _locationWatcher.Stop(); System.Diagnostics.Debug.WriteLine($"Lat: {Lat} Lng: {Lng}"); }
public void Start() { if (_watcher.Started == false) { _watcher.OnPermissionChanged += _permissionChanged; _watcher.Start(new MvxLocationOptions() { Accuracy = MvxLocationAccuracy.Fine, TrackingMode = MvxLocationTrackingMode.Foreground, }, _onLocation, _onError); } }
public LocationService(IMvxLocationWatcher watcher, IMvxMessenger messenger) { _watcher = watcher; _messenger = messenger; var options = new MvxLocationOptions() { Accuracy = MvxLocationAccuracy.Fine, MovementThresholdInM = 5, TrackingMode = MvxLocationTrackingMode.Foreground }; _watcher.Start(options, OnLocation, OnError); OnLocation(_watcher.CurrentLocation); }
public FirstViewModel(ICustomerService customerService, IMvxLocationWatcher watcher) { _customerService = customerService; _watcher = watcher; if (_watcher != null) { if (!_watcher.Started) _watcher.Start(new MvxLocationOptions(), OnLocationFound, OnError); } if (string.IsNullOrWhiteSpace(Lat) || string.IsNullOrWhiteSpace(Lon)) { Lat = "12.950545"; Lon = "77.642149"; } }
public LocationService(IMvxLocationWatcher watcher, IMvxMessenger messenger) { _watcher = watcher; _messenger = messenger; _locationMessage = new LocationMessage(this); _updateLoc_token = _messenger.Subscribe <UpdateLocMessage>(OnUpdateLocMessage); var options = new MvxLocationOptions { Accuracy = MvxLocationAccuracy.Fine, TimeBetweenUpdates = TimeSpan.FromSeconds(2), TrackingMode = MvxLocationTrackingMode.Foreground }; _watcher.Start(options, OnLocation, OnError); }
public Task <MvxGeoLocation> GetLocation(CancellationTokenSource tokenSource = null) { var tcs = new TaskCompletionSource <MvxGeoLocation>(); StopLocationWatcher(); _locationWatcher.Start(new MvxLocationOptions() { Accuracy = MvxLocationAccuracy.Coarse, TrackingMode = MvxLocationTrackingMode.Background }, location => { tcs.TrySetResult(location); _locationWatcher.Stop(); }, error => { tcs.TrySetResult(null); }); Task.Run(async() => { if (tokenSource != null) { await Task.Delay(60000, tokenSource.Token); } else { await Task.Delay(60000); } if (!tcs.Task.IsCompleted) { MvxGeoLocation currLocation = null; try { currLocation = _locationWatcher.CurrentLocation; } catch { } tcs.TrySetResult(currLocation); } }); return(tcs.Task); }
private Task <Location> CalculatePositionInternalAsync() { var tcs = new TaskCompletionSource <Location>(); _watcher.Start( new MvxLocationOptions { Accuracy = MvxLocationAccuracy.Fine, MovementThresholdInM = 150, TimeBetweenUpdates = new TimeSpan(0, 0, 0, 15) }, location => tcs.TrySetResult(new Location { Latitude = location.Coordinates.Latitude, Longitude = location.Coordinates.Longitude }), error => tcs.TrySetException(new Exception(error.Code.ToString()))); return(tcs.Task); }
public MvxGeoLocation LastLocation() { if (_watcher.Started) { return(_watcher.CurrentLocation); } else { var options = new MvxLocationOptions() { Accuracy = MvxLocationAccuracy.Fine, MovementThresholdInM = 5, TrackingMode = MvxLocationTrackingMode.Foreground }; _watcher.Start(options, OnLocation, OnError); return(_watcher.CurrentLocation); } }
public StartViewModel(IMvxNavigationService navigationService, IMvxLocationWatcher watcher) { _navigation = navigationService; _watcher = watcher; _watcher.Start(new MvxLocationOptions(), OnLocation, OnError); SearchCmd = new MvxCommand(() => { _navigation.Navigate <PostsViewModel, SearchModel>(new SearchModel { KeyWord = this.KeyWord, StartDate = this.StartDate, EndDate = this.EndDate }); }); EndDate = DateTime.Now.ToShortDateString(); SetLocationCmd = new MvxCommand(() => { // Long = _watcher.CurrentLocation.Coordinates.Longitude; // Lat = _watcher.CurrentLocation.Coordinates.Latitude; Location = "Lublin"; }); }
private void StartWatcher() { Console.WriteLine("StartWatcher"); _dispatcher.ExecuteOnMainThreadAsync(() => { if (_locationWatcher.Started) { Console.WriteLine("Watcher already started!"); return; } _locationWatcher.Start(new MvxLocationOptions() { Accuracy = MvxLocationAccuracy.Coarse }, location => { _locationWatcher.Stop(); OnSuccess(new MvxCoordinates() { Latitude = location.Coordinates.Latitude, Longitude = location.Coordinates.Longitude }); }, error => { _locationWatcher.Stop(); Console.WriteLine(error.Code); OnError(new Exception(error.Code.ToString())); }); Task.Delay(_timeOut).ContinueWith(_ => OnTimeout()); }); }
void InitializeLocation(MvxLocationOptions locationOptions) { _location.Start(locationOptions, onLocation, onError); }
public LocationService(IMvxLocationWatcher watcher, IMvxMessenger messenger) { _watcher = watcher; _messenger = messenger; _watcher.Start(new MvxLocationOptions(), OnLocation, OnError); }
public Child3ViewModel(IMvxLocationWatcher watcher) { _watcher = watcher; _watcher.Start(new MvxLocationOptions(), OnFix, OnError); LocationEntity = new ObservableCollection <LocationEntity>(Parameters.LocationEntityManager.GetItems().ToList()); }
public Child3ViewModel(IMvxLocationWatcher watcher) { _watcher = watcher; _watcher.Start(new MvxLocationOptions(), OnFix, OnError); }
public FirstViewModel(IMvxLocationWatcher watcher) { _watcher = watcher; _watcher.Start(new MvxLocationOptions(), OnLocation, OnError); }
public void StartLocationWatcher(MvxLocationOptions options) { _watcher.Start(options, OnLocation, OnError); }
public FirstViewModel(IMvxLocationWatcher watcher) { _watcher = watcher; _watcher.Start(new MvxLocationOptions(), OnLocation, OnError); }