private void OnLocatorStatusChanged(Geolocator sender, StatusChangedEventArgs e)
        {
            GeolocationException geolocationException;

            switch (e.Status)
            {
            case PositionStatus.Disabled:
                geolocationException = new GeolocationUnauthorizedException();
                break;

            case PositionStatus.NoData:
                geolocationException = new GeolocationPositionUnavailableException();
                break;

            default:
                return;
            }

            if (this.IsListening)
            {
                this.StopListening();
                this.OnPositionError(new PositionErrorEventArgs(geolocationException));
            }

            this.locator = null;
        }
Example #2
0
        private void WatcherOnStatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
        {
            this.isEnabled = (this.watcher.Permission == GeoPositionPermission.Granted && this.watcher.Status != GeoPositionStatus.Disabled);

            GeolocationException geolocationException;

            switch (e.Status)
            {
            case GeoPositionStatus.Disabled:
                geolocationException = new GeolocationUnauthorizedException();
                break;

            case GeoPositionStatus.NoData:
                geolocationException = new GeolocationPositionUnavailableException();
                break;

            default:
                return;
            }

            this.StopListening();

            var perror = this.PositionError;

            if (perror != null)
            {
                perror(this, new PositionErrorEventArgs(geolocationException));
            }
        }