Esempio n. 1
0
        public async void StartLocationUpdates()
        {
            LocationsAggregator = await LocationsAggregator.GetInstance();

            LocationManager locationManager = (LocationManager)this.GetSystemService(Context.LocationService);

            locationManager.RequestLocationUpdates(LocationManager.GpsProvider, AppConfiguration.MINIMUM_TIME_MS,
                                                   AppConfiguration.MINIMUM_DISTANCE_M, this);
        }
Esempio n. 2
0
        public async void StartLocationUpdates()
        {
            // We need the user's permission for our app to use the GPS in iOS. This is done either by the user accepting
            // the popover when the app is first launched, or by changing the permissions for the app in Settings
            if (CLLocationManager.LocationServicesEnabled)
            {
                //set the desired accuracy, in meters
                LocationManager.DesiredAccuracy = CLLocation.AccuracyBest;
                LocationManager.DistanceFilter  = AppConfiguration.MINIMUM_DISTANCE_M;

                LocationsAggregator = await LocationsAggregator.GetInstance();

                LocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
                    foreach (CLLocation location in e.Locations)
                    {
                        LocationsAggregator.RecordLocation(location.Coordinate.Longitude, location.Coordinate.Latitude,
                                                           location.Course, location.Speed, location.HorizontalAccuracy);
                    }
                };

                LocationManager.StartUpdatingLocation();
            }
        }