private async void OnHelperSearch(object sender, EventArgs e) { if (!string.IsNullOrEmpty(entrySearch.Text)) { listView.IsVisible = false; listView.SelectedItem = null; string selectedLoc = entrySearch.Text; //selectedLoc = selectedLoc.Split(',')[0]; var loc = selectedPrediction.Where(x => x.Description == selectedLoc).FirstOrDefault(); selectedPlace = await Places.GetPlace(loc.Place_ID, Constants.googlePlaceApiKey); HelpersServices helpersServices = new HelpersServices(); var h = await helpersServices.GetHelpersList(0, selectedService.Id, selectedScope.Id, selectedPlace.Latitude, selectedPlace.Longitude); if (filteredLocationType != '\0') { h = h.Where(x => x.LocationType.Equals(filteredLocationType)); } if (h != null && h.Count() != 0) { helpersViewModel.SetLocationOnMap(new ObservableCollection <HelperHomeModel>(h)); } } }
private async void OnPlacesRetrieved(object sender, AutoCompleteResult result) { if (!(result.Status == "OK")) { return; } ObservableCollection <LocationModel> addresses = new ObservableCollection <LocationModel>(); //List<string> addresses = new List<string>(); List <AutoCompletePrediction> selectedPrediction = result.AutoCompletePlaces; foreach (AutoCompletePrediction autoCompletePlace in result.AutoCompletePlaces) { Place place = await Places.GetPlace(autoCompletePlace.Place_ID, Constants.googlePlaceApiKey); addresses.Add(new LocationModel { Address = autoCompletePlace.Description, Latitude = place.Latitude.ToString(), Longitude = place.Longitude.ToString() }); } if (addresses.Count == 0) { return; } lvAddresses.ItemsSource = addresses; }
private async Task HandlePlacePredictionTap(AutoCompletePrediction prediction) { if (FromAutoCompletePredictions != null) { IsFromVisible = false; _selectedFromPlace = prediction; FromAutoCompletePredictions = null; FromText = prediction.Description; var place = await Places.GetPlace(prediction.Place_ID, App.GooglePlacesApi); NewRide.FromLong = place.Longitude; NewRide.FromLat = place.Latitude; NewRide.FromCity = place.Name; } else { IsToVisible = false; _selectedToPlace = prediction; ToAutoCompletePredictions = null; ToText = prediction.Description; var place = await Places.GetPlace(prediction.Place_ID, App.GooglePlacesApi); NewRide.ToLong = place.Longitude; NewRide.ToLat = place.Latitude; NewRide.ToCity = place.Name; } }
private async void OnLocationSelected(object sender, ItemTappedEventArgs e) { string selectedLoc = ((ListView)sender).SelectedItem.ToString(); entrySearch.Text = selectedLoc; AutoCompletePrediction p = selectedPrediction.Where(x => x.Description == selectedLoc).FirstOrDefault(); selectedPlace = await Places.GetPlace(p.Place_ID, Constants.googlePlaceApiKey); listView.IsVisible = false; listView.SelectedItem = null; flag = false; }
async void Results_List_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } var prediction = (AutoCompletePrediction)e.SelectedItem; results_list.SelectedItem = null; var place = await Places.GetPlace(prediction.Place_ID, GooglePlacesApiKey); if (place != null) { await DisplayAlert( place.Name, string.Format("Lat: {0}\nLon: {1}", place.Latitude, place.Longitude), "OK"); } }
async void Results_List_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } var prediction = (AutoCompletePrediction)e.SelectedItem; results_list.SelectedItem = null; place = await Places.GetPlace(prediction.Place_ID, search_bar.ApiKey); if (place != null) { LocationName.Text = "Location: " + place.Name; PlaceId = prediction.Place_ID; Trace.WriteLine("PlaceId: " + PlaceId); } }
async private void Results_List_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } var prediction = (AutoCompletePrediction)e.SelectedItem; Results_list.SelectedItem = null; var place = await Places.GetPlace(prediction.Place_ID, googlePlacesApi); if (!string.IsNullOrWhiteSpace(place.Name)) { MessagingCenter.Send(this, "LocationTeam", place.Name); MessagingCenter.Send(this, "LocationFilter", place.Name); MessagingCenter.Send(this, "LocationDetails", (place.Latitude, place.Longitude)); } await PopupNavigation.Instance.PopAsync(); }
private async void ResultsList_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } var prediction = (AutoCompletePrediction)e.SelectedItem; ResultsList.SelectedItem = null; var place = await Places.GetPlace(prediction.Place_ID, StoredData.GoogleApiKey); if (place != null) { ResultsList.IsVisible = false; MoveMap(new Location(place.Latitude, place.Longitude)); await Navigation.PushModalAsync(new ParksListModal(new Location(place.Latitude, place.Longitude))); } }
async void Results_List_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem == null) { return; } var prediction = (AutoCompletePrediction)e.SelectedItem; results_list.SelectedItem = null; var place = await Places.GetPlace(prediction.Place_ID, GooglePlacesApiKey); if (place != null) { Settings.CurrentLatitude = place.Latitude; Settings.CurrentLongitude = place.Longitude; await DisplayAlert( place.Name, "You are here!", "OK");//string.Format("Lat: {0}\nLon: {1}", place.Latitude, place.Longitude), "OK"); } await Navigation.PopModalAsync(); }
public async void GetPlaceIDEditEvent() { PlaceId = group.MeetupLocationId; place = await Places.GetPlace(group.MeetupLocationId, search_bar.ApiKey); }
private async void OnClickPostJob(object sender, EventArgs e) { aiPostJob.IsRunning = true; JobPostModel jpm = new JobPostModel(); string text = entryPJTitle.Text; if (text == null || text.Equals("")) { await DisplayAlert("", "Please enter Job Title.", "OK"); aiPostJob.IsRunning = false; } else { jpm.JobTitle = text; string l = entryPJLocation.Text; if (l == null || l.Equals("")) { await DisplayAlert("", "Please enter Job Location.", "OK"); aiPostJob.IsRunning = false; } else { try { Place place = await Places.GetPlace(selectedPrediction.Place_ID, Constants.googlePlaceApiKey); jpm.Location = new List <LocationModel>() { new LocationModel() { LocationName = l, Latitude = place.Latitude.ToString(), Longitude = place.Longitude.ToString() } }; } catch (Exception ex) { Console.Write(ex.StackTrace); } jpm.JobType = !rgPJJobStatus.SelectedItem.ToString().ToLower().Equals("normal") ? "U" : "N"; ServiceModel serviceModel = services.ElementAt <ServiceModel>(selectedService); jpm.JobServicesId = serviceModel.Id; jpm.JobServicesName = serviceModel.ServiceName; //if (serviceModel.ServiceName.Equals("Child Care")) if (serviceModel.ServiceName.ToLower().Contains("child")) { jpm.Receivers = new List <Receiver>(); for (int i = 0; i < gridChildCare.Children.Count - 1; i++) { ChildView content = (ChildView)gridChildCare.Children[i]; Grid grid = (Grid)content.Children.ElementAt(0); RadioGroup radioGroup = (RadioGroup)grid.Children.ElementAt(1); Button button = (Button)grid.Children.ElementAt(3); int gender = (new List <string>() { "Male", "Female", "N/A" }).IndexOf(radioGroup.SelectedItem.ToString()); jpm.Receivers.Add(new Receiver() { ReceiverAge = (int)float.Parse(button.Text), ReceiverGender = gender + 1 }); } } jpm.HelperType = !cbPJHelperHome.Checked ? "M" : "S"; if (btnPJPriceTbd.BorderColor == Color.FromHex("BCC1C4")) { if (btnPJPriceDaily.BorderColor == Color.FromHex("FE7890")) { jpm.IsDaily = true; jpm.MinDailyPrice = btnPJPriceDayMin.Text.Substring(2); jpm.MaxDailyPrice = btnPJPriceDayMax.Text.Substring(2); } if (btnPJPriceMonthly.BorderColor == Color.FromHex("FE7890")) { jpm.IsMonthly = true; jpm.MinMonthlyPrice = btnPJPriceMonthMin.Text.Substring(2); jpm.MaxMonthlyPrice = btnPJPriceMonthMax.Text.Substring(2); } if (btnPJPriceHourly.BorderColor == Color.FromHex("FE7890")) { jpm.IsHourly = true; jpm.MinHourlyPrice = btnPJPriceHrMin.Text.Substring(2); jpm.MaxHourlyPrice = btnPJPriceHrMax.Text.Substring(2); } } if (entryPJDescription.Text != null) { jpm.JobDescription = entryPJDescription.Text; } if (btnPJSun.BorderColor == Color.FromHex("FE7890")) { jpm.IsSunday = true; } if (btnPJMon.BorderColor == Color.FromHex("FE7890")) { jpm.IsMonday = true; } if (btnPJTue.BorderColor == Color.FromHex("FE7890")) { jpm.IsTuesday = true; } if (btnPJWed.BorderColor == Color.FromHex("FE7890")) { jpm.IsWednesday = true; } if (btnPJThu.BorderColor == Color.FromHex("FE7890")) { jpm.IsThursday = true; } if (btnPJFri.BorderColor == Color.FromHex("FE7890")) { jpm.IsFriday = true; } if (btnPJSat.BorderColor == Color.FromHex("FE7890")) { jpm.IsSaturday = true; } //jpm.StartTime = rsPJTime.LowerValue / 60 + ":" + rsPJTime.LowerValue % 60 + ":00"; //jpm.EndTime = rsPJTime.UpperValue / 60 + ":" + rsPJTime.UpperValue % 60 + ":00"; jpm.StartTime = btnPJStartTime.Text.Substring(0, 2) + ":" + btnPJStartTime.Text.Substring(2, 2) + ":00"; jpm.EndTime = btnPJEndTime.Text.Substring(0, 2) + ":" + btnPJEndTime.Text.Substring(2, 2) + ":00"; jpm.JobScope = new List <JobScopes>(); foreach (Button button in gridPJScopes.Children.ToList()) { if (button.BorderColor == Color.FromHex("FE7890")) { string scope = button.Text; var s = scopes.Where((x => x.ScopeName == scope)).FirstOrDefault(); jpm.JobScope.Add(new JobScopes() { ScopeId = s.Id.ToString(), ScopeName = s.ScopeName }); } } jpm.UserId = loggedUser.Id; int num = await new JobServices().SaveJob(jpm) ? 1 : 0; aiPostJob.IsRunning = false; if (num != 0) { await DisplayAlert("", "Job Post successfully.", "OK"); Page page = await Navigation.PopAsync(); } else { await DisplayAlert("", "Job not post. Please try again.", "OK"); } } } }
async void Results_List_ItemSelected(object sender, SelectedItemChangedEventArgs e) { try { if (e.SelectedItem == null) { return; } var prediction = (AutoCompletePrediction)e.SelectedItem; results_list.SelectedItem = null; var FullAddress = prediction.Description; // Helpers.Commom.PlaceName = FullAddress; var place = await Places.GetPlace(prediction.Place_ID, GooglePlacesApiKey); //if (place != null) // await DisplayAlert( // place.Name, string.Format("Lat: {0}\nLon: {1}", place.Latitude, place.Longitude), "OK"); if (place != null) { var PlaceName = place.Name; var Latitude = place.Latitude; var Longitude = place.Longitude; search_bar.Text = PlaceName; } await OriginAddress(); placeListGrid.IsVisible = false; //if (addTravelerTripPage3VM == null) //{ Helpers.Constant.originLatitude = place.Latitude.ToString(); Helpers.Constant.originLongitude = place.Longitude.ToString(); // await OriginAddress(); // okButton.IsVisible = true; //} //else if (addTravelerTripPage3VM != null) //{ // OrderReceiveLatitude = place.Latitude; // OrderReceiveLongitude = place.Longitude; // Helpers.Commom.OrderLatitude = OrderReceiveLatitude; // Helpers.Commom.OrderLongitude = OrderReceiveLongitude; // await DestinationAddress(); // okButton.IsVisible = true; //} //if (addTripPageVM.DestinationCountryName == "Destination Address") //{ // Helpers.Commom.DestinationLatitude = place.Latitude.ToString(); // Helpers.Commom.DestinationLongitude = place.Longitude.ToString(); // await DestinationAddress(); // okButton.IsVisible = true; //} //else //{ // address.Text= "Please Enter Your Origin Address"; // search_bar.Placeholder = "Origin Address"; // search_bar.PlaceholderColor = Color.Black; // search_bar.FontSize = 13; // Helpers.Commom.originLatitude = place.Latitude.ToString(); // Helpers.Commom.originLongitude = place.Longitude.ToString(); // await OriginAddress(); // okButton.IsVisible = true; //} } catch (Exception ex) { ex.ToString(); } }
private async Task <Place> GetPlaceAsync(string placeId) { return(await Places.GetPlace(placeId, ConstantHelper.GoogleApiKey)); }
private async void OnSaveBasicInfo(object sender, EventArgs e) { aiEditBasicInfo.IsRunning = true; if (string.IsNullOrEmpty(entryEditBasicInfoPhone.Text)) { await DisplayAlert("Warning", "Please enter phone number", "Ok"); } else if (string.IsNullOrEmpty(entryEditBasicInfoEmail.Text)) { await DisplayAlert("Warning", "Please enter email", "Ok"); } else if (!Utils.IsValidMobileNo(entryEditBasicInfoPhone.Text)) { await DisplayAlert("Warning", "Please enter valid mobile number", "Ok"); } else if (!Utils.IsValidEmail(entryEditBasicInfoEmail.Text)) { await DisplayAlert("Warning", "Please enter valid email", "Ok"); } else { var ui = ((EditBasicInfoViewModel)BindingContext).UserInfo; try { Gender g = (Gender)Enum.Parse(typeof(Gender), rgEditBasicInfoGender.SelectedItem.ToString()); ui.Gender = (int)g; } catch { ui.Gender = 3; } ui.MobileNumber = entryEditBasicInfoPhone.Text; ui.Email = entryEditBasicInfoEmail.Text; if (!string.IsNullOrEmpty(entryEditBasicInfoLocation.Text)) { if (ui.LocationName.Equals(entryEditBasicInfoLocation.Text)) { ui.LocationName = entryEditBasicInfoLocation.Text; try { Place place = await Places.GetPlace(selectedPrediction.Place_ID, Constants.googlePlaceApiKey); ui.Latitude = place.Latitude.ToString(); ui.Longitude = place.Longitude.ToString(); } catch (Exception ex) { Console.Write(ex.StackTrace); } } } if (!string.IsNullOrEmpty(entryEditBasicInfoIntroduction.Text)) { ui.selfintroduction = entryEditBasicInfoIntroduction.Text; } bool result = await(new LoginServices()).SaveUserBasicInfo(ui); if (result) { await Navigation.PopAsync(); } else { await DisplayAlert("", "Please try again.", "Ok"); } } aiEditBasicInfo.IsRunning = false; }