示例#1
0
        public async Task GetPlacesDetail(GooglePlaceAutoCompletePrediction placeA)
        {
            var place = await googleMapsApi.GetPlaceDetails(placeA.PlaceId);

            if (place != null)
            {
                if (_isPickupFocused)
                {
                    PickupText       = place.Name;
                    _originLatitud   = $"{place.Latitude}";
                    _originLongitud  = $"{place.Longitude}";
                    _isPickupFocused = false;
                    FocusOriginCommand.Execute(null);
                }
                else
                {
                    _destinationLatitud  = $"{place.Latitude}";
                    _destinationLongitud = $"{place.Longitude}";

                    RecentPlaces.Add(placeA);

                    if (_originLatitud == _destinationLatitud && _originLongitud == _destinationLongitud)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Origin route should be different than destination route", "Ok");
                    }
                    else
                    {
                        LoadRouteCommand.Execute(null);
                        await App.Current.MainPage.Navigation.PopAsync(false);

                        CleanFields();
                    }
                }
            }
        }
        public async Task GetPlacesDetail(GooglePlaceAutoCompletePrediction placeA)
        {
            var place = await googleMapsApi.GetPlaceDetails(placeA.PlaceId);

            if (place != null)
            {
                if (isPickupFocused)
                {
                    PickupText      = place.Name;
                    latitude        = $"{place.Latitude}";
                    longitude       = $"{place.Longitude}";
                    isPickupFocused = false;
                    FocusOriginCommand.Execute(null);
                }
                else
                {
                    destinationLatitude  = $"{place.Latitude}";
                    destiantionLongitude = $"{place.Longitude}";

                    RecentPlaces.Add(placeA);
                    CleanFields();

                    searchedPlace = true;
                    await GetActualName();
                }
            }
        }
示例#3
0
        public async Task SaveEntry(GooglePlaceAutoCompletePrediction placeA)
        {
            var place = await googleMapsApi.GetPlaceDetails(placeA.PlaceId);

            if (place != null)
            {
                PickupText      = place.Name;
                Entry.Latitude  = place.Latitude;
                Entry.Longitude = place.Longitude;
                Entry.Address   = place.Name;

                if (IsBusy)
                {
                    return;
                }

                IsBusy = true;

                try
                {
                    await _cateringService.AddEntryAsync(Entry);

                    await NavService.NavigateTo <MainViewModel>();

                    await NavService.ClearBackStack();

                    await NavService.ClearBackStack();
                }
                finally
                {
                    IsBusy = false;
                }
            }
        }
示例#4
0
        private async Task SetPlaceSelectedOnMap(GooglePlaceAutoCompletePrediction placeA)
        {
            var place = await googleMapsApi.GetPlaceDetails(placeA.PlaceId);

            if (place != null)
            {
                if (_isOriginFocused)
                {
                    Origin           = place.Name;
                    _originLatitud   = $"{place.Latitude}";
                    _originLongitud  = $"{place.Longitude}";
                    _isOriginFocused = false;
                    if (StartPin != null)
                    {
                        Map.Pins.Remove(StartPin);
                    }
                    StartPin = CreatePin(Constants.ORIGEN_LABEL, place.Latitude, place.Longitude);
                    Start    = new Geocode(place.Latitude, place.Longitude);
                    Map.Pins.Add(StartPin);
                    if (!_isOriginFocused && isOneDirection)
                    {
                        await App.Current.MainPage.Navigation.PopModalAsync(false);

                        _isOriginFocused = true;
                        CleanFields();
                        return;
                    }
                }
                else
                {
                    Destination          = place.Name;
                    _destinationLatitud  = $"{place.Latitude}";
                    _destinationLongitud = $"{place.Longitude}";
                    if (EndPin != null)
                    {
                        Map.Pins.Remove(EndPin);
                    }
                    EndPin = CreatePin(Constants.DESTINO_LABEL, place.Latitude, place.Longitude);
                    End    = new Geocode(place.Latitude, place.Longitude);
                    Map.Pins.Add(EndPin);

                    if (_originLatitud == _destinationLatitud && _originLongitud == _destinationLongitud)
                    {
                        await App.Current.MainPage.DisplayAlert("Ups", "El origen y el destino no pueden ser los mismos.", "Ok");
                    }
                    else
                    {
                        LoadRouteCommand.Execute(null);
                        await App.Current.MainPage.Navigation.PopModalAsync(false);

                        CleanFields();
                    }
                }
            }
        }
        public async Task GetPlacesDetail(GooglePlaceAutoCompletePrediction placeA)
        {
            var place = await googleMapsApi.GetPlaceDetails(placeA.PlaceId);

            if (place != null)
            {
                DestinationCoordinates = new Location(place.Latitude, place.Longitude);
                LoadRouteCommand.Execute(null);
                RecentPlaces.Add(placeA);
            }
        }
示例#6
0
        public async Task GetPlacesDetail(GooglePlaceAutoCompletePrediction placeA)
        {
            var place = await googleMapsApi.GetPlaceDetails(placeA.PlaceId);

            if (place != null)
            {
                _destinationLatitud  = $"{place.Latitude}";
                _destinationLongitud = $"{place.Longitude}";

                RecentPlaces.Add(placeA);
            }
        }
示例#7
0
        public async Task GetPlacesDetail(GooglePlaceAutoCompletePrediction placeA)
        {
            var place = await googleMapsApi.GetPlaceDetails(placeA.PlaceId);



            if (place != null)
            {
                if (_isPickupFocused)
                {
                    PickupText       = place.Name;
                    _originLatitud   = $"{place.Latitude}";
                    _originLongitud  = $"{place.Longitude}";
                    _isPickupFocused = false;
                    FocusOriginCommand.Execute(null);
                }
                else
                {
                    _destinationLatitud  = $"{place.Latitude}";
                    _destinationLongitud = $"{place.Longitude}";

                    RecentPlaces.Add(placeA);

                    if (_originLatitud == _destinationLatitud && _originLongitud == _destinationLongitud)
                    {
                        await Application.Current.MainPage.DisplayAlert("Error", "Origin route should be different than Destination route", "Ok");
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(_originLatitud) || string.IsNullOrEmpty(_originLongitud))
                        {
                            await Application.Current.MainPage.DisplayAlert("Error", "Enter and select Origin from the list", "Ok");
                        }

                        else
                        {
                            LoadRouteCommand.Execute(null);

                            var masterDetailPage = Application.Current.MainPage as MasterDetailPage;



                            await masterDetailPage.Detail.Navigation.PopAsync();


                            CleanFields();
                        }
                    }
                }
            }
        }
        public async Task GetPlacesDetail(GooglePlaceAutoCompletePrediction placeA)
        {
            try
            {
                var place = await googleMapsApi.GetPlaceDetails(placeA.PlaceId);

                if (place != null)
                {
                    if (_isPickupFocused)
                    {
                        PickupText       = place.Name;
                        startLabel       = placeA.StructuredFormatting.MainText;
                        startAdd         = placeA.StructuredFormatting.SecondaryText;
                        _originLatitud   = $"{place.Latitude}";
                        _originLongitud  = $"{place.Longitude}";
                        _isPickupFocused = false;
                        destEntry.Focus();
                    }
                    else
                    {
                        OriginText = place.Name;
                        endLabel   = placeA.StructuredFormatting.MainText;
                        endAdd     = placeA.StructuredFormatting.SecondaryText;

                        _destinationLatitud  = $"{place.Latitude}";
                        _destinationLongitud = $"{place.Longitude}";

                        if (_originLatitud == _destinationLatitud && _originLongitud == _destinationLongitud)
                        {
                            await App.Current.MainPage.DisplayAlert("Error", "Origin route should be different than destination route", "Ok");
                        }
                        else
                        {
                            LoadRouteCommand.Execute(null);
                            await App.Current.MainPage.Navigation.PopModalAsync(true);

                            CleanFields();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#9
0
        private async void ExecuteSelect(GooglePlaceAutoCompletePrediction address)
        {
            try
            {
                //_navigationService.Navigate<AddressMapViewModel, GooglePlaceAutoCompletePrediction>(address);
                var place = await _googleMapsApiService.GetPlaceDetails(address.PlaceId);

                address.Place = place;

                _messenger.Publish(new AddressResult(this, address.ToMapTable()));
            }
            catch (Exception ex)
            {
                _quickMessageDependency.ShowToastMessage(ex.Message);
            }
            await _navigationService.Close(this);

            //ShowViewModel<AddressMapViewModel, GooglePlaceAutoCompletePrediction>(address);
        }
示例#10
0
        public async Task GetPlacesDetail(GooglePlaceAutoCompletePrediction placeA)
        {
            var place = await googleMapsApi.GetPlaceDetails(placeA.PlaceId);

            if (place != null)
            {
                if (_isPickupFocused)
                {
                    PickupText       = place.Name;
                    _originLatitud   = $"{place.Latitude}";
                    _originLongitud  = $"{place.Longitude}";
                    _isPickupFocused = false;
                    FocusOriginCommand.Execute(null);
                }
                else
                {
                    _destinationLatitud  = $"{place.Latitude}";
                    _destinationLongitud = $"{place.Longitude}";

                    RecentPlaces.Add(placeA);

                    if (_originLatitud == _destinationLatitud && _originLongitud == _destinationLongitud)
                    {
                        var search = new MapView();
                        await App.Current.MainPage.DisplayAlert("", "Please Click the Search Button", "Ok");
                    }
                    else
                    {
                        LoadRouteCommand.Execute(null);
                        await App.Current.MainPage.Navigation.PopModalAsync(false);

                        CleanFields();
                    }
                }
            }
        }