コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.SelectAddressActivity);

            var txtSearch     = FindViewById <EditText>(Resource.Id.txtSearch);
            var txtNoInternet = FindViewById <TextView>(Resource.Id.txtNoInternet);

            txtSearch.TextChanged += TxtSearch_TextChanged;
            var listSearch = FindViewById <ListView>(Resource.Id.listSearch);

            listSearch.ItemClick += async(o, ea) =>
            {
                var placeAutoSearch = Adapter[ea.Position];

                var googlePlace = await googleMapsApi.GetPlaceDetails(placeAutoSearch.PlaceId);

                Shell.AppDatabase.InsertGooglePlace(googlePlace);

                SetResult(Result.Ok);
                Finish();
            };

            var current = Connectivity.NetworkAccess;

            txtSearch.Visibility     = current == NetworkAccess.Internet ? ViewStates.Visible : ViewStates.Gone;
            txtNoInternet.Visibility = current == NetworkAccess.Internet ? ViewStates.Gone : ViewStates.Visible;

            Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged;
        }
コード例 #2
0
        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();
                }
            }
        }
        private void searchResultsDestination_ItemSelected(object sender, SelectionChangedEventArgs e)
        {
            string destination = e.CurrentSelection.First().ToString();

            viewModel.DestinationLocation      = destination;
            searchResultsDestination.IsVisible = false;
            for (int i = 0; i < viewModel.destinationPredictionsList.Count; i++)
            {
                if (viewModel.destinationPredictionsList[i].Description == destination)
                {
                    GooglePlace placeDetails = googleMapsApi.GetPlaceDetails(viewModel.destinationPredictionsList[i].PlaceId).Result;
                    viewModel._destinationLatitude  = placeDetails.Latitude + "";
                    viewModel._destinationLongitude = placeDetails.Longitude + "";
                }
            }
        }
コード例 #4
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();
                    }
                }
            }
        }
コード例 #5
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;
                }
            }
        }
コード例 #6
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();
                    }
                }
            }
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
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);
            }
        }
コード例 #9
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();
                        }
                    }
                }
            }
        }
コード例 #10
0
        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;
            }
        }
コード例 #11
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);
        }
コード例 #12
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();
                    }
                }
            }
        }