Esempio n. 1
0
        public async void LoadMore()
        {
            string url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?pagetoken=" + nextPageToken + "&key=AIzaSyCK8SquzPry-orS9Lc80hXbPyVUhIyni_Y";

            try
            {
                HttpClient client   = new HttpClient();
                var        response = await client.GetStringAsync(string.Format(url));

                var result = JsonConvert.DeserializeObject <PlacesApiQueryResponse>(response.ToString());
                foreach (var item in result.results)
                {
                    PlaceViewModel place = new PlaceViewModel()
                    {
                        Name   = item.name,
                        Rating = item.rating,
                        Icon   = item.icon
                    };

                    Places.Add(place);

                    System.Diagnostics.Debug.WriteLine(place.Name);
                }
            }
            catch (Exception ex)
            { }
        }
Esempio n. 2
0
        private async void LoadData()
        {
            string url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&rankby=distance&types=food&key=AIzaSyCK8SquzPry-orS9Lc80hXbPyVUhIyni_Y";

            try
            {
                HttpClient client   = new HttpClient();
                var        response = await client.GetStringAsync(string.Format(url));

                var result = JsonConvert.DeserializeObject <PlacesApiQueryResponse>(response.ToString());
                foreach (var item in result.results)
                {
                    PlaceViewModel place = new PlaceViewModel()
                    {
                        Name   = item.name,
                        Rating = item.rating,
                        Icon   = item.icon,
                    };
                    Places.Add(place);
                    System.Diagnostics.Debug.WriteLine(place.Name);
                }

                var result1 = JsonConvert.DeserializeObject <PlacesApiQueryResponse>(response.ToString());
                nextPageToken = result1.next_page_token;
                System.Diagnostics.Debug.WriteLine(nextPageToken);
            }
            catch (Exception ex)
            { }
        }
Esempio n. 3
0
        private void Remove(object phoneObj)
        {
            PlaceViewModel phone = phoneObj as PlaceViewModel;

            if (phone == null)
            {
                return;
            }

            Places.Remove(phone);
        }
Esempio n. 4
0
        private void MoveToBottom(object phoneObj)
        {
            PlaceViewModel phone = phoneObj as PlaceViewModel;

            if (phone == null)
            {
                return;
            }
            int oldIndex = Places.IndexOf(phone);

            if (oldIndex < Places.Count - 1)
            {
                Places.Move(oldIndex, oldIndex + 1);
            }
        }
Esempio n. 5
0
        private void MoveToTop(object phoneObj)
        {
            PlaceViewModel phone = phoneObj as PlaceViewModel;

            if (phone == null)
            {
                return;
            }
            int oldIndex = Places.IndexOf(phone);

            if (oldIndex > 0)
            {
                Places.Move(oldIndex, oldIndex - 1);
            }
        }
Esempio n. 6
0
        public async void SearchByClient(string query)
        {
            Places.Clear();
            string url        = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=";
            Char   delimiter  = ' ';
            var    substrings = query.Split(delimiter);

            for (int i = 0; i < substrings.Length; i++)
            {
                if (i != substrings.Length)
                {
                    System.Diagnostics.Debug.WriteLine(substrings[i]);
                    url += substrings[i];
                }
            }

            url += "&key=AIzaSyCK8SquzPry-orS9Lc80hXbPyVUhIyni_Y";
            System.Diagnostics.Debug.WriteLine(url);
            /* restaurants+in+Sydney";*/
            try
            {
                HttpClient client   = new HttpClient();
                var        response = await client.GetStringAsync(string.Format(url));

                System.Diagnostics.Debug.WriteLine(response);

                var result = JsonConvert.DeserializeObject <PlacesApiQueryResponse>(response.ToString());
                foreach (var item in result.results)
                {
                    PlaceViewModel place = new PlaceViewModel()
                    {
                        Name   = item.name,
                        Rating = item.rating,
                        Icon   = item.icon
                    };

                    Places.Add(place);

                    System.Diagnostics.Debug.WriteLine(place.Name);
                }
            }
            catch (Exception ex)
            { }
        }