Пример #1
0
        public MapPage(IGeolocatorService geolocatorService)
        {
            InitializeComponent();
            _geolocatorService = geolocatorService;

            MoveMapToCurrentPositionAsync();
        }
Пример #2
0
 public CountryPage(
     IGeolocatorService geolocatorService)
 {
     InitializeComponent();
     _geolocatorService = geolocatorService;
     MoveMapToCurrentCountryAsync();
 }
Пример #3
0
 public StartTripPage(IGeolocatorService geolocatorService)
 {
     InitializeComponent();
     _geolocatorService = geolocatorService;
     _instance          = this;
     _distance          = .2;
 }
        public MainMapViewModel(
            IRequestService requestService,
            ILayerService layerService,
            IGeolocatorService geolocatorService,
            INavigationService navigationService,
            IHexagonal hexagonal,
            IHeatGradientService heatGradientService,
            IZoneService zoneService)
        {
            _requestService      = requestService;
            _layerService        = layerService;
            _geolocatorService   = geolocatorService;
            _navigationService   = navigationService;
            _hexagonal           = hexagonal;
            _heatGradientService = heatGradientService;
            _zoneService         = zoneService;

            Initialized         = false;
            _layerLast          = 0;
            _currentPositionTag = String.Empty;
            _currentPosition    = _geolocatorService.LastRecordedPosition;
            //MainMapInitialCameraUpdate = CameraUpdateFactory.NewPositionZoom(_currentPosition, 12.0); // zoom can be within: [2,21]
            CameraPosition cp = new CameraPosition(_currentPosition, 12.0, 0.0, 60.0);

            MainMapInitialCameraUpdate = CameraUpdateFactory.NewCameraPosition(cp);
        }
 /// <summary>
 /// Observes the location permission.
 /// </summary>
 public static IObservable <bool> ObserveIsPermissionGranted(this IGeolocatorService service)
 {
     return(Observable.FromEventPattern <LocationPermissionChangedEventHandler, LocationPermissionChangedEventArgs>(
                h => service.LocationPermissionChanged += h,
                h => service.LocationPermissionChanged -= h
                )
            .Select(p => p.EventArgs.IsLocationPermissionGranted));
 }
 /// <summary>
 /// Observes the user's location.
 /// </summary>
 public static IObservable <Geocoordinate> ObserveLocation(this IGeolocatorService service)
 {
     return(Observable.FromEventPattern <LocationChangedEventHandler, LocationChangedEventArgs> (
                h => service.LocationChanged += h,
                h => service.LocationChanged -= h
                )
            .Select(p => p.EventArgs.Coordinate));
 }
        private static async Task GetInitialLocationOrDefault(this IGeolocatorService service, IObserver <Geocoordinate> observer, CancellationToken ct)
        {
            var isPermissionGranted = await service.RequestPermission(ct);

            var currentLocationOrNull = isPermissionGranted ? await service.GetLocationOrDefault(ct) : null;

            observer.OnNext(currentLocationOrNull);
        }
 public ParkPage(IGeolocatorService geolocatorService,
                 IApiService apiService)
 {
     InitializeComponent();
     _geolocatorService = geolocatorService;
     _apiService        = apiService;
     ShowParkAsync();
 }
Пример #9
0
 public MapPage(IGeolocatorService geolocatorService, IApiService apiService)
 {
     InitializeComponent();
     _geolocatorService = geolocatorService;
     _apiService        = apiService;
     MoveMapToCurrentPositionAsync();
     ShowPropertiesAsync();
 }
Пример #10
0
        public MapsPage(IGeolocatorService geolocatorService, IApiService apiService, INavigationService navigationService)
        {
            InitializeComponent();

            _geolocatorService = geolocatorService;

            _apiService        = apiService;
            _navigationService = navigationService;
        }
 /// <summary>
 /// Attempts to obtain the location and indicates whether this was successful. See <see cref="LocationResult"/>
 /// </summary>
 public static async Task <LocationResult> TryGetLocation(this IGeolocatorService locationService, CancellationToken ct)
 {
     try
     {
         return(new LocationResult(isSuccessful: true, location: await locationService.GetLocation(ct)));
     }
     catch (InvalidOperationException)
     {
         return(new LocationResult(isSuccessful: false, location: default));
        /// <summary>
        /// Gets and observes the user's location (or null if it's unavailable). Requests the permission if this was not already done.
        /// The location becomes null as soon as the location permission is denied.
        /// </summary>
        public static IObservable <Geocoordinate> GetAndObserveLocationOrDefault(this IGeolocatorService service)
        {
            var initialLocationOrNull         = Observable.Create <Geocoordinate>(service.GetInitialLocationOrDefault);
            var locationObservable            = ObserveLocation(service);
            var locationUnavailableObservable = ObserveIsPermissionGranted(service)
                                                .Where(isGranted => !isGranted)
                                                .Select(_ => default(Geocoordinate));

            return(Observable.Merge(initialLocationOrNull, locationObservable, locationUnavailableObservable));
        }
Пример #13
0
 public EndTripPageViewModel(INavigationService navigationService, IApiService apiService, IGeolocatorService geolocatorService)
     : base(navigationService)
 {
     _navigationService = navigationService;
     _apiService        = apiService;
     _geolocatorService = geolocatorService;
     Title     = Languages.EndTrip;
     IsEnabled = true;
     Comments  = new ObservableCollection <Comment>(CombosHelper.GetComments());
 }
        public CustomGoogleMap(IGeolocatorService geolocatorService)
        {
            _geolocatorService = geolocatorService;

            //var location = new Position(30.4, -97.7);
            var location = _geolocatorService.LastRecordedPosition;
            var cf       = CameraUpdateFactory.NewPositionZoom(location, 13.0);

            this.InitialCameraUpdate = cf;
        }
Пример #15
0
 public MapasPage(
     IGeolocatorService geolocatorService,
     IApiService apiService)
 {
     InitializeComponent();
     _geolocatorService = geolocatorService;
     _apiService        = apiService;
     ShowOwnersAsync();
     MoveMapToCurrentPositionAsync();
 }
Пример #16
0
 public CablesMapPage(IGeolocatorService geolocatorService)
 {
     InitializeComponent();
     _geolocatorService = geolocatorService;
     MyMap.MapType      = MapType.Street;
     MyMap.IsVisible    = false;
     MoveMapToCurrentPositionAsync();
     MyMap.IsVisible = true;
     ShowPinsAsync();
 }
 /// <summary>
 /// Gets the current location. Does not throw an <see cref="InvalidOperationException"/> when that location is unavailable
 /// (for instance, because of lacking permissions) but rather returns null.
 /// </summary>
 public static async Task <Geocoordinate> GetLocationOrDefault(this IGeolocatorService locationService, CancellationToken ct)
 {
     try
     {
         return(await locationService.GetLocation(ct));
     }
     catch (InvalidOperationException)
     {
         return(null);
     }
 }
Пример #18
0
 public MapPage(IGeolocatorService geolocatorService,
                IApiService apiService)
 {
     InitializeComponent();
     mp.MapType         = MapType.Street;
     ma2.Source         = "satellite.png";
     _geolocatorService = geolocatorService;
     _apiService        = apiService;
     ShowPropertiesAsync();
     MoveMapToCurrentPositionAsync();
 }
Пример #19
0
 public RegisterPageViewModel(
     INavigationService navigationService,
     IApiService apiService,
     IGeolocatorService geolocatorService) : base(navigationService)
 {
     _navigationService = navigationService;
     _apiService        = apiService;
     _geolocatorService = geolocatorService;
     Title     = "Register new user";
     IsEnabled = true;
 }
Пример #20
0
 public FindClosestPlacesCommand(
     IPlaces placesApi,
     IGeolocatorService geoLocator,
     ICategoriesService categoryService,
     CancellationToken cancellationToken)
 {
     this.categoryService   = categoryService;
     this.cancellationToken = cancellationToken;
     this.geoLocator        = geoLocator;
     this.placesApi         = placesApi;
 }
Пример #21
0
 public RegisterPageViewModel(
     INavigationService navigationService,
     IApiService apiService,
     IGeolocatorService geolocatorService) : base(navigationService)
 {
     Title              = Languages.RegisterNewUser;
     IsEnabled          = true;
     _navigationService = navigationService;
     _apiService        = apiService;
     _geolocatorService = geolocatorService;
 }
Пример #22
0
 public ReportPageViewModel(INavigationService navigationService, IGeolocatorService geolocatorService,
                            IApiService apiService, IFilesHelper filesHelper) : base(navigationService)
 {
     _navigationService = navigationService;
     _geolocatorService = geolocatorService;
     _apiService        = apiService;
     _filesHelper       = filesHelper;
     ReportRequest      = new ReportRequest();
     Image = App.Current.Resources["UrlNoImage"].ToString();
     Title = Languages.CreateReport;
     LoadSourceAsync();
 }
Пример #23
0
 public ProfilePageViewModel(
     INavigationService navigationService,
     IApiService apiService,
     IGeolocatorService geolocatorService) : base(navigationService)
 {
     Title              = Languages.MyProfile;
     IsEnabled          = true;
     Owner              = JsonConvert.DeserializeObject <OwnerResponse>(Settings.Owner);
     _geolocatorService = geolocatorService;
     _navigationService = navigationService;
     _apiService        = apiService;
 }
Пример #24
0
 public ReportPageViewModel(
     INavigationService navigationService,
     IApiService apiService,
     IGeolocatorService geolocatorService)
     : base(navigationService)
 {
     Title              = "Reporte un incidente";
     IsEnabled          = true;
     _navigationService = navigationService;
     _apiService        = apiService;
     _geolocatorService = geolocatorService;
 }
Пример #25
0
 public ReportPageViewModel(
     INavigationService navigationService,
     IApiService apiService,
     IGeolocatorService geolocatorService)
     : base(navigationService)
 {
     Title              = Languages.ReportAnIncident;
     IsEnabled          = true;
     _navigationService = navigationService;
     _apiService        = apiService;
     _geolocatorService = geolocatorService;
 }
Пример #26
0
 public RegisterViewModel(INavigationService navigationService,
                          IApiService apiService,
                          IGeolocatorService geolocatorService)
     : base(navigationService)
 {
     _navigationService = navigationService;
     _apiService        = apiService;
     _geolocatorService = geolocatorService;
     Title     = Languages.Register1;
     IsEnabled = true;
     LoadRoles();
 }
Пример #27
0
 public AddLocationPageViewModel(
     INavigationService navigationService,
     IApiService apiService,
     IGeolocatorService geolocatorService) : base(navigationService)
 {
     _navigationService = navigationService;
     _apiService        = apiService;
     _geolocatorService = geolocatorService;
     Title              = "Add Location";
     IsEnabled          = true;
     Location           = new EstablishmentLocationRequest();
     TypeEstablishments = new ObservableCollection <TypeEstablishmentResponse>(CombosHelper.GetTypeEstablishment());
     Cities             = new ObservableCollection <CityResponse>(CombosHelper.GetCities());
 }
Пример #28
0
 public StartTripPageViewModel(INavigationService navigationService, IGeolocatorService geolocatorService, IApiService apiService)
     : base(navigationService)
 {
     _navigationService = navigationService;
     _geolocatorService = geolocatorService;
     _apiService        = apiService;
     Title               = Languages.StartTrip;
     ButtonLabel         = Languages.StartTrip;
     _tripDetailsRequest = new TripDetailsRequest {
         TripDetails = new List <TripDetailRequest>()
     };
     IsEnabled = true;
     LoadSourceAsync();
 }
Пример #29
0
        //private readonly IDialogService _dialogService;

        public ZoneMapViewModel(
            ILayerService layerService,
            IGeolocatorService geolocatorService,
            INavigationService navigationService)
        //IDialogService dialogService)
        {
            _layerService      = layerService;
            _geolocatorService = geolocatorService;
            _navigationService = navigationService;
            //_dialogService = dialogService;
            IsBusy = true;
            var cp = _geolocatorService.LastRecordedPosition;

            MapRegion = MapSpan.FromCenterAndRadius(cp, Distance.FromKilometers(1.2));
        }
 public RegisterPageViewModel(
     INavigationService navigationService,
     IRegexHelper regexHelper,
     IApiService apiService,
     IFilesHelper filesHelper,
     IGeolocatorService geolocatorService)
     : base(navigationService)
 {
     _navigationService = navigationService;
     _regexHelper       = regexHelper;
     _apiService        = apiService;
     _filesHelper       = filesHelper;
     _geolocatorService = geolocatorService;
     Title     = Languages.Register;
     Image     = App.Current.Resources["UrlNoImage"].ToString();
     IsEnabled = true;
     User      = new UserRequest();
     LoadCountriesAsync();
 }