Beispiel #1
0
        public object Search(string latitude, string longitude, string type)
        {
            string apiKey = WebConfigurationManager.AppSettings["GoogleApiKey"];

            NearbySearchRequest request = new NearbySearchRequest(apiKey, latitude, longitude, "1000", type);

            try
            {
                NearbySearchResponse result = request.Execute();

                return(JsonConvert.SerializeObject(result.Results.Select(
                                                       x => new object[]
                {
                    x.Icon,
                    x.Name,
                    x.Opening_hours != null ? x.Opening_hours.Open_now ? "YES" : "NO" : "",
                    x.Types.Select(y => y.Replace("_", " ")).Aggregate((a, b) => a + ", " + b),
                    x.Vicinity
                })
                                                   ));
            }
            catch (ApplicationException ex)
            {
                return(string.Empty);
            }
        }
        public void OnSearchResult(Java.Lang.Object results)
        {
            NearbySearchResponse nearbySearchResponse = (NearbySearchResponse)results;

            if (nearbySearchResponse != null && nearbySearchResponse.TotalCount > 0)
            {
                context.SetSearchResultOnMap(nearbySearchResponse.Sites);
            }
        }
        /// <summary>
        /// Obtains the search result.
        /// </summary>
        public void OnSearchResult(Java.Lang.Object results)
        {
            restaurants = new List <Restaurant>();
            NearbySearchResponse nearbySearchResponse = (NearbySearchResponse)results;

            foreach (Site site in nearbySearchResponse.Sites)
            {
                restaurants.Add(new Restaurant()
                {
                    Name         = site.Name,
                    Location     = new Position(site.Location.Lat, site.Location.Lng),
                    Adress       = site.Address.AdminArea,
                    AdressDetail = site.Address.Locality + " " + site.Address.SubLocality + " " + site.Address.Thoroughfare,
                    Phone        = site.Poi.Phone,
                    Ratings      = site.Poi.Rating
                });
            }

            tcsResult.TrySetResult(true);
        }
            public void OnSearchResult(Java.Lang.Object resultObject)
            {
                NearbySearchResponse nearbySearchResponse = (NearbySearchResponse)resultObject;

                AddSitesToResultTextView(nearbySearchResponse.Sites);
            }