/// <summary> /// A string specifying two lat/lng pairs in decimal degrees, representing the south/west and north/east points of a rectangle. /// </summary> public static LocationBias Rectangular(IGeoCoordinatesLocation southWest, IGeoCoordinatesLocation northEast) { if (southWest.Longitude < -180 || southWest.Longitude > 180) { throw new ArgumentOutOfRangeException(nameof(southWest)); } if (northEast.Longitude < -180 || northEast.Longitude > 180) { throw new ArgumentOutOfRangeException(nameof(northEast)); } if (southWest.Latitude < -90 || southWest.Latitude > 90) { throw new ArgumentOutOfRangeException(nameof(southWest)); } if (northEast.Latitude < -90 || northEast.Latitude > 90) { throw new ArgumentOutOfRangeException(nameof(northEast)); } return(new LocationBias($"rectangle:{southWest.Latitude},{southWest.Longitude}|{northEast.Latitude},{northEast.Longitude}")); }
/// <summary> /// Point: A single lat/lng coordinate /// </summary> public static LocationBias Point(IGeoCoordinatesLocation location) { return(Point(location.Latitude, location.Longitude)); }
/// <summary> /// A string specifying radius in meters, plus lat/lng in decimal degrees. /// </summary> public static LocationBias Circular(int radius, IGeoCoordinatesLocation location) { return(Circular(radius, location.Latitude, location.Longitude)); }
/// <summary> /// Lets you search for places within a specified area. /// Google Maps APIs Premium Plan customers should not include a client or signature parameter with their requests. /// </summary> /// <param name="location">The latitude/longitude around which to retrieve place information</param> /// <param name="radius">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.</param> /// <param name="language">The language code, indicating in which language the results should be returned, if possible.</param> /// <param name="minprice">Restricts results to only those places within the specified range.</param> /// <param name="maxPrice">Restricts results to only those places within the specified range.</param> /// <param name="name">One or more terms to be matched against the names of places</param> /// <param name="openNow">Returns only those places that are open for business at the time the query is sent.</param> /// <param name="rankBy">The order in which results are listed</param> /// <param name="placeType">Restricts the results to places matching the specified type.</param> /// <param name="pageToken">Returns the next 20 results from a previously run search</param> /// <param name="zagatSelected">Restrict your search to locations that are Zagat selected businesses</param> /// <returns>Result</returns> public PlaceSearchResponse NearbySearch(IGeoCoordinatesLocation location, int?radius = null, string keyword = null, string language = null, int?minprice = null, int?maxPrice = null, IEnumerable <string> name = null, bool?openNow = null, PlaceRankByEnum?rankBy = null, PlaceSearchTypeEnum?placeType = null, string pageToken = null, bool?zagatSelected = null) { // Validations if (rankBy.HasValue && rankBy.Value == PlaceRankByEnum.Distance) { if (!(keyword != null || name != null || placeType != null)) { throw new ArgumentException( "Either a keyword, name, or type arg is required when rankBy is set to Distance"); } if (radius != null) { throw new ArgumentException("Radius cannot be specified when rankBY is set to Distance"); } } // Assign query params var queryParams = new QueryParams { ["location"] = Converter.Location(location) }; // Radius if (radius.HasValue) { queryParams["radius"] = Converter.Number(radius.Value); } // Keyword if (keyword != null) { queryParams["keyword"] = keyword; } // Language if (language != null) { queryParams["language"] = language; } // Min/Max price if (minprice.HasValue) { queryParams["minprice"] = Converter.Number(minprice.Value); } if (maxPrice.HasValue) { queryParams["maxprice"] = Converter.Number(maxPrice.Value); } // Name if (name != null) { queryParams["name"] = Converter.JoinList(name); } // Open now if (openNow.HasValue) { queryParams["opennow"] = Converter.Value(openNow.Value); } // Rank by if (rankBy.HasValue) { queryParams["rankby"] = rankBy.Value.GetSerializationName(); } // Place type if (placeType.HasValue) { queryParams["type"] = placeType.Value.GetSerializationName(); } // Page token if (pageToken != null) { queryParams["pagetoken"] = pageToken; } // Zatgat selected if (zagatSelected.HasValue) { queryParams["zatgatselected"] = ""; } // Get API response result var response = Client.APIGet <PlaceSearchResponse>("/maps/api/place/nearbysearch/json", queryParams); // Return it return(response); }
/// <summary> /// Returns the shortest representation of the given location. /// /// The Elevations API limits requests to 2000 characters, and accepts /// multiple locations either as pipe-delimited lat/lng values, or /// an encoded polyline, so we determine which is shortest and use it. /// </summary> /// <param name="location">Location</param> /// <returns>Shortest representation</returns> public static string ShortestPath(IGeoCoordinatesLocation location) { return(ShortestPath(new List <IGeoCoordinatesLocation> { location })); }
/// <summary> /// Returns Place predictions given a textual search query, such as /// "pizza near New York", and optional geographic bounds. /// </summary> /// <param name="input">The text query on which to search</param> /// <param name="offset">The position, in the input term, of the last character that /// the service uses to match predictions.For example, if the input is 'Google' and /// the offset is 3, the service will match on 'Goo'.</param> /// <param name="location">The latitude/longitude value for which you wish to obtain /// the closest, human-readable address.</param> /// <param name="radius">The distance (in meters) within which to return place results.</param> /// <param name="language">The language code, indicating in which language the results should be returned, if possible</param> /// <returns>Result</returns> public PlaceQueryAutoCompleteResponse QueryAutoComplete(string input, int?offset = null, IGeoCoordinatesLocation location = null, int?radius = null, string language = null) { // Assign query params var queryParams = new QueryParams { ["input"] = input }; // Offset if (offset.HasValue) { queryParams["offset"] = Converter.Number(offset.Value); } // Location if (location != null) { queryParams["location"] = Converter.Location(location); } // Radius if (radius.HasValue) { queryParams["radius"] = Converter.Number(radius.Value); } // Language if (language != null) { queryParams["language"] = language; } // Get API response result var response = Client.APIGet <PlaceQueryAutoCompleteResponse>("/maps/api/place/queryautocomplete/json", queryParams); // Return it return(response); }
/// <summary> /// Returns Place predictions given a textual search string and optional geographic bounds. /// </summary> /// <param name="input">The text string on which to search</param> /// <param name="offset">The position, in the input term, of the last character that /// the service uses to match predictions.For example, if the input is 'Google' and /// the offset is 3, the service will match on 'Goo'.</param> /// <param name="location">The latitude/longitude value for which you wish to obtain /// the closest, human-readable address.</param> /// <param name="radius">The distance (in meters) within which to return place results.</param> /// <param name="language">The language code, indicating in which language the results should be returned, if possible</param> /// <param name="types">The types of place results to return</param> /// <param name="components">A grouping of places to which you would like to restrict your results.</param> /// <returns>Result</returns> public PlaceAutocompleteResponse AutoComplete(string input, int?offset = null, IGeoCoordinatesLocation location = null, int?radius = null, string language = null, IEnumerable <string> types = null, ComponentsFilter components = null) { // Assign query params var queryParams = new QueryParams { ["input"] = input }; // Offset if (offset.HasValue) { queryParams["offset"] = Converter.Number(offset.Value); } // Location if (location != null) { queryParams["location"] = Converter.Location(location); } // Radius if (radius.HasValue) { queryParams["radius"] = Converter.Number(radius.Value); } // Language if (language != null) { queryParams["language"] = language; } // Types if (types != null) { queryParams["types"] = Converter.JoinList(types); } // Components if (components != null) { queryParams["components"] = Converter.Components(components); } // Get API response result var response = Client.APIGet <PlaceAutocompleteResponse>("/maps/api/place/autocomplete/json", queryParams); // Return it return(response); }
/// <summary> /// Returns information about a set of places based on a string /// </summary> /// <param name="query">The text string on which to search,</param> /// <param name="location">The latitude/longitude around which to retrieve place information</param> /// <param name="radius">the distance (in meters) within which to return place results. The maximum allowed /// radius is 50 000 meters.</param> /// <param name="language">The language code, indicating in which language the results should be returned, if possible.</param> /// <param name="minprice">Restricts results to only those places within the specified range.</param> /// <param name="maxPrice">Restricts results to only those places within the specified range.</param> /// <param name="openNow">Returns only those places that are open for business at the time the query is sent.</param> /// <param name="placeType">Restricts the results to places matching the specified type.</param> /// <param name="pageToken">Returns the next 20 results from a previously run search</param> /// <param name="zagatSelected">Restrict your search to locations that are Zagat selected businesses</param> /// <returns>Results</returns> public PlaceSearchResponse TextSearch(string query, IGeoCoordinatesLocation location = null, int?radius = null, string language = null, int?minprice = null, int?maxPrice = null, bool?openNow = null, PlaceSearchTypeEnum?placeType = null, string pageToken = null, bool?zagatSelected = null) { // Assign query params var queryParams = new QueryParams { ["query"] = query }; // Location if (location != null) { queryParams["location"] = Converter.Location(location); } // Radius if (radius.HasValue) { queryParams["radius"] = Converter.Number(radius.Value); } // Language if (language != null) { queryParams["language"] = language; } // Min/Max price if (minprice.HasValue) { queryParams["minprice"] = Converter.Number(minprice.Value); } if (maxPrice.HasValue) { queryParams["maxprice"] = Converter.Number(maxPrice.Value); } // Open now if (openNow.HasValue) { queryParams["opennow"] = Converter.Value(openNow.Value); } // Place type if (placeType.HasValue) { queryParams["type"] = placeType.Value.GetSerializationName(); } // Page token if (pageToken != null) { queryParams["pagetoken"] = pageToken; } // Zatgat selected if (zagatSelected.HasValue) { queryParams["zatgatselected"] = ""; } // Get API response result var response = Client.APIGet <PlaceSearchResponse>("/maps/api/place/textsearch/json", queryParams); // Return it return(response); }
/// <summary> /// Get the posted speed limit for a given road segment /// </summary> /// <param name="path">The path to be snapped</param> /// <param name="units">Speed limits units</param> /// <returns>result</returns> public SpeedLimitsResponse SpeedLimits(IGeoCoordinatesLocation path, SpeedUnitEnum?units = null) { return(SpeedLimits(new List <IGeoCoordinatesLocation> { path }, units)); }
/// <summary> /// takes up to 100 GPS points collected along a route, and returns a similar set of data, with the points snapped /// to the most likely roads the vehicle was traveling along /// </summary> /// <param name="path">The path to be snapped</param> /// <param name="interpolate">Whether to interpolate a path to include all points forming the full road-geometry</param> /// <returns>Result</returns> public SnapToRoadsResponse SnapToRoads(IGeoCoordinatesLocation path, bool?interpolate = null) { return(SnapToRoads(new List <IGeoCoordinatesLocation> { path }, interpolate)); }