public static async Task <Rootobject> TextSearch(string query, Geopoint Location = null, int Radius = 0, string Region = "", string NextPageToken = "", SearchPriceEnum MinPrice = SearchPriceEnum.NonSpecified, SearchPriceEnum MaxPrice = SearchPriceEnum.NonSpecified, PlaceTypesEnum type = PlaceTypesEnum.NOTMENTIONED) { try { if (Radius > 50000) { throw new IndexOutOfRangeException("Radious Value is out of expected range."); } if (Location != null && Radius == 0) { throw new Exception("Location and radius values must having values"); } string para = ""; para += $"query={query.Replace(" ", "+")}"; if (Location != null) { para += $"&location={Location.Position.Latitude},{Location.Position.Longitude}&radius={Radius}"; } if (Region != "") { para += $"®ion={Region}"; } if (MinPrice != SearchPriceEnum.NonSpecified) { para += $"&minprice={(int)MinPrice}"; } if (MaxPrice != SearchPriceEnum.NonSpecified) { para += $"&maxprice={(int)MaxPrice}"; } if (type != PlaceTypesEnum.NOTMENTIONED) { para += $"&type={type.ToString()}"; } para += $"&language={Initializer.GoogleMapRequestsLanguage}&key={Initializer.GoogleMapAPIKey}"; var http = Initializer.httpclient; var st = await http.GetStringAsync(new Uri("https://maps.googleapis.com/maps/api/place/textsearch/json?" + para, UriKind.RelativeOrAbsolute)); return(JsonConvert.DeserializeObject <Rootobject>(st)); } catch { return(null); } }
/// <summary> /// Search nearby places in the mentioned Radius /// </summary> /// <param name="Location"> The latitude/longitude around which to retrieve place information. This must be specified as latitude,longitude</param> /// <param name="Radius">Defines the distance (in meters) within which to return place results. The maximum allowed radius is 50 000 meters. </param> /// <param name="Keyword">A term to be matched against all content that Google has indexed for this place, including but not limited to name, type, and address, as well as customer reviews and other third-party content.</param> /// <param name="MinPrice">Restricts results to only those places within the specified range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive.</param> /// <param name="MaxPrice">Restricts results to only those places within the specified range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive.</param> /// <returns>Search Result. LOL :D</returns> public static async Task <Rootobject> NearbySearch(BasicGeoposition Location, int Radius, string Keyword = "", SearchPriceEnum MinPrice = SearchPriceEnum.NonSpecified, SearchPriceEnum MaxPrice = SearchPriceEnum.NonSpecified, PlaceTypesEnum type = PlaceTypesEnum.NOTMENTIONED) { try { if (Radius > 50000) { throw new IndexOutOfRangeException("Radious Value is out of expected range."); } string para = ""; para += $"location={Location.Latitude},{Location.Longitude}&radius={Radius}"; if (Keyword != "") { para += $"&keyword={Keyword}"; } if (MinPrice != SearchPriceEnum.NonSpecified) { para += $"&minprice={(int)MinPrice}"; } if (MaxPrice != SearchPriceEnum.NonSpecified) { para += $"&maxprice={(int)MaxPrice}"; } if (type != PlaceTypesEnum.NOTMENTIONED) { para += $"&type={type.ToString()}"; } para += $"&key={Initializer.GoogleMapAPIKey}&language={Initializer.GoogleMapRequestsLanguage}"; var http = Initializer.httpclient; var st = await http.GetStringAsync(new Uri("https://maps.googleapis.com/maps/api/place/nearbysearch/json?" + para, UriKind.RelativeOrAbsolute)); return(JsonConvert.DeserializeObject <Rootobject>(st)); } catch { return(null); } }