Struct google_maps::places::place_autocomplete::request::Request
source · pub struct Request<'a> { /* private fields */ }
Expand description
Look at this Request
struct for documentation on how to build your
Place Autocomplete query. The methods implemented for this struct are
what’s used to build your request.
Implementations§
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub async fn execute(
&'a mut self,
) -> Result<PlaceAutocompleteResponse, GoogleMapsError>
pub async fn execute( &'a mut self, ) -> Result<PlaceAutocompleteResponse, GoogleMapsError>
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub async fn get(
&mut self,
) -> Result<PlaceAutocompleteResponse, GoogleMapsError>
pub async fn get( &mut self, ) -> Result<PlaceAutocompleteResponse, GoogleMapsError>
Performs the HTTP get request and returns the response to the caller.
§Arguments
This method accepts no arguments.
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn new(client: &GoogleMapsClient, input: impl Into<String>) -> Request<'_>
pub fn new(client: &GoogleMapsClient, input: impl Into<String>) -> Request<'_>
Initializes the builder pattern for a Place API Place Autocomplete query with the required, non-optional parameters.
§Arguments
-
client
‧ Your application’s Google Maps API client struct. -
input
‧ The text string on which to search.
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn query_url(&'a mut self) -> String
pub fn query_url(&'a mut self) -> String
Returns the URL query string that represents the query you’ve built.
§Description
Returns the query string that will be sent to the Places API. It is the result of the builder pattern. This method could be useful for records or logging. It could also be used for passing to your HTTP client of choice and executing the HTTP GET request yourself.
§Arguments
This method accepts no arguments.
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn with_component(&'a mut self, component: Country) -> &'a mut Self
pub fn with_component(&'a mut self, component: Country) -> &'a mut Self
Adds the components parameter to the Place API Place Autocomplete query.
§Arguments
-
component
‧ A grouping of places to which you would like to restrict your results. Currently, you can use components to filter by up to 5 countries. -
Multiple components may be stacked together.
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn with_components<C, O>(&'a mut self, components: C) -> &'a mut Self
pub fn with_components<C, O>(&'a mut self, components: C) -> &'a mut Self
Adds the components parameter to the Place API Place Autocomplete query.
§Arguments
-
components
‧ A grouping of places to which you would like to restrict your results. Currently, you can use components to filter by up to 5 countries. -
Multiple components may be stacked together.
§Generics
This method uses generics to improve ergonomics. The C
generic is
intended to represent any collection that can be iterated over, and the
O
generic is for any type that can be converted to the Country
type.
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn with_language(&'a mut self, language: Language) -> &'a mut Self
pub fn with_language(&'a mut self, language: Language) -> &'a mut Self
Adds the language parameter to the Place API Place Autocomplete query.
§Arguments
-
language
‧ The language in which to return results.-
See the list of supported languages. Google often updates the supported languages, so this list may not be exhaustive.
-
If
language
is not supplied, the API attempts to use the preferred language as specified in theAccept-Language
header. -
The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.
-
If a name is not available in the preferred language, the API uses the closest match.
-
The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and tér are synonyms for street in Hungarian.
-
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn with_location_and_radius(
&'a mut self,
location: impl Into<LatLng>,
radius: u32,
) -> &'a mut Self
pub fn with_location_and_radius( &'a mut self, location: impl Into<LatLng>, radius: u32, ) -> &'a mut Self
Adds the location and radius parameters to the Place API Place Autocomplete query.
§Arguments
-
location
‧ The point around which to retrieve place information. Note: When using the Text Search API, thelocation
parameter may be overriden if thequery
contains an explicit location such asMarket in Barcelona
. -
radius
‧ Defines the distance (in meters) within which to return place results. You may bias results to a specified circle by passing alocation
and aradius
parameter. Doing so instructs the Places service to prefer showing results within that circle; results outside of the defined area may still be displayed.
The radius will automatically be clamped to a maximum value depending on the type of search and other parameters.
- Autocomplete: 50,000 meters
- Nearby Search:
- with
keyword
orname
: 50,000 meters - without
keyword
orname
- Up to 50,000 meters, adjusted dynamically based on area
density, independent of
rankby
parameter. - When using
rankby=distance
, the radius parameter will not be accepted, and will result in anINVALID_REQUEST
.
- Up to 50,000 meters, adjusted dynamically based on area
density, independent of
- with
- Query Autocomplete: 50,000 meters
- Text Search: 50,000 meters
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn with_strict_location_and_radius(
&'a mut self,
location: impl Into<LatLng>,
radius: u32,
) -> &'a mut Self
pub fn with_strict_location_and_radius( &'a mut self, location: impl Into<LatLng>, radius: u32, ) -> &'a mut Self
Adds the location and radius parameters to the Place API Place Autocomplete query.
§Arguments
-
location
‧ The point around which to retrieve place information. Note: When using the Text Search API, thelocation
parameter may be overriden if thequery
contains an explicit location such asMarket in Barcelona
. -
radius
‧ Defines the distance (in meters) within which to return place results. You may bias results to a specified circle by passing alocation
and aradius
parameter. Doing so instructs the Places service to prefer showing results within that circle; results outside of the defined area may still be displayed. The radius will automatically be clamped to a maximum value depending on the type of search and other parameters. -
strictbounds
‧ Returns only those places that are strictly within the region defined bylocation
andradius
. This is a restriction, rather than a bias, meaning that results outside this region will not be returned even if they match the user input.
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn with_offset(&'a mut self, offset: u8) -> &'a mut Self
pub fn with_offset(&'a mut self, offset: u8) -> &'a mut Self
Adds the offset parameter to the Place API Place Autocomplete query.
§Arguments
offset
‧ The position, in the input term, of the last character that the service uses to match predictions. For example, if the input isGoogle
and the offset is 3, the service will match onGoo
. The string determined by the offset is matched against the first word in the input term only. For example, if the input term isGoogle abc
and the offset is 3, the service will attempt to match againstGoo abc
. If no offset is supplied, the service will use the whole term. The offset should generally be set to the position of the text caret.
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn with_origin(&'a mut self, origin: impl Into<LatLng>) -> &'a mut Self
pub fn with_origin(&'a mut self, origin: impl Into<LatLng>) -> &'a mut Self
Adds the origin parameter to the Place API Place Autocomplete query.
§Arguments
origin
‧ The origin point from which to calculate straight-line distance to the destination (returned asdistance_meters
). If this value is omitted, straight-line distance will not be returned.
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn with_region(&'a mut self, region: Region) -> &'a mut Self
pub fn with_region(&'a mut self, region: Region) -> &'a mut Self
Adds the region parameter to the Place API Place Autocomplete query.
§Arguments
region
‧ The region code, specified as a ccTLD (“top-level domain”) two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom’s ccTLD is “uk” (.co.uk) while its ISO 3166-1 code is “gb” (technically for the entity of “The United Kingdom of Great Britain and Northern Ireland”).
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn with_sessiontoken(
&'a mut self,
sessiontoken: impl Into<String>,
) -> &'a mut Self
pub fn with_sessiontoken( &'a mut self, sessiontoken: impl Into<String>, ) -> &'a mut Self
Adds the session token parameter to the Place API Place Autocomplete query.
§Arguments
sessiontoken
‧ A random string which identifies an autocomplete session for billing purposes.
The session begins when the user starts typing a query, and concludes
when they select a place and a call to Place Details is made. Each
session can have multiple queries, followed by one place selection. The
API key(s) used for each request within a session must belong to the
same Google Cloud Console project. Once a session has concluded, the
token is no longer valid; your app must generate a fresh token for each
session. If the sessiontoken
parameter is omitted, or if you reuse a
session token, the session is charged as if no session token was
provided (each request is billed separately).
We recommend the following guidelines:
-
Use session tokens for all autocomplete sessions.
-
Generate a fresh token for each session. Using a version 4 UUID is recommended.
-
Ensure that the API key(s) used for all Place Autocomplete and Place Details requests within a session belong to the same Cloud Console project.
-
Be sure to pass a unique session token for each new session. Using the same token for more than one session will result in each request being billed individually.
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn with_type(
&'a mut self,
autocomplete_type: AutocompleteType,
) -> &'a mut Self
pub fn with_type( &'a mut self, autocomplete_type: AutocompleteType, ) -> &'a mut Self
Adds the types parameter to the Place API Place Autocomplete query.
§Arguments
-
types
‧ You may restrict results from a Place Autocomplete request to be of a certain type by passing a types parameter. The parameter specifies a type or a type collection, as listed in the supported types below. If nothing is specified, all types are returned. In general only a single type is allowed. The exception is that you can safely mix the geocode and establishment types, but note that this will have the same effect as specifying no types. -
Multiple result type filters may be stacked together.
source§impl<'a> Request<'a>
impl<'a> Request<'a>
sourcepub fn with_types<C, A>(&'a mut self, types: C) -> &'a mut Self
pub fn with_types<C, A>(&'a mut self, types: C) -> &'a mut Self
Adds the types parameter to the Place API Place Autocomplete query.
§Arguments
-
types
‧ You may restrict results from a Place Autocomplete request to be of a certain type by passing a types parameter. The parameter specifies a type or a type collection, as listed in the supported types below. If nothing is specified, all types are returned. In general only a single type is allowed. The exception is that you can safely mix the geocode and establishment types, but note that this will have the same effect as specifying no types. -
Multiple result type filters may be stacked together.
§Generics
This method uses generics to improve ergonomics. The C
generic is
intended to represent any collection that can be iterated over, and the
A
generic is for any type that can be converted to the
AutocompleteType
type.