Exemplo n.º 1
0
        async Task <bool> GetPlaces(string locationName, string location = null)
        {
            locationList.Clear();

            Place result = await rest.GetPlaces(locationName, location);

            if (result != null)
            {
                if (result.predictions.Count > 0)
                {
                    foreach (var item in result.predictions)
                    {
                        var cell = new TextCell()
                        {
                            Text = item.description,
                        };
                        cell.Tapped += (sender, e) => {
                            if (isHomeSelected)
                            {
                                parent.origin    = item.description;
                                parent.isHomeSet = 1;
                            }
                            else
                            {
                                parent.destination      = item.description;
                                parent.isDestinationSet = 1;
                            }

                            recentSearchList.Add(item.description);
                            App.Current.Properties["recentList"] = JsonConvert.SerializeObject(recentSearchList);
                            Navigation.PopModalAsync();
                        };
                        locationList.Add(cell);
                    }
                    return(true);
                }
                else
                {
                    Debug.WriteLine("Could not get info of home address");
                    return(false);
                }
            }
            else
            {
                Debug.WriteLine("Geocoder returns no results");
                return(false);
            }
        }