[][src]Struct google_maps::geocoding::forward::ForwardRequest

pub struct ForwardRequest<'a> { /* fields omitted */ }

Look at this Request struct for documentation on how to build your Geocoding API query. The methods implemented for this struct are what's used to build your request. Forward geocoding looks up a longitude & latitude coordinates from a street address.

Implementations

impl<'a> ForwardRequest<'a>[src]

pub fn build(&mut self) -> Result<&'a mut ForwardRequest, Error>[src]

Builds the query string for the Google Maps Geocoding API based on the input provided by the client.

Arguments:

This method accepts no arguments.

impl<'a> ForwardRequest<'a>[src]

pub fn execute(&'a mut self) -> Result<Response, Error>[src]

Executes the query you've built.

Description:

My adventures in Rust became messy so I had to make this method. It wraps the .validate()?.build()?.get()? chain needed at the end of the builder pattern.

Arguments:

This method accepts no arguments.

impl<'a> ForwardRequest<'a>[src]

pub fn get(&mut self) -> Result<Response, Error>[src]

Performs the HTTP get request and returns the response to the caller.

Arguments:

This method accepts no arguments.

impl<'a> ForwardRequest<'a>[src]

pub fn new(client_settings: &mut ClientSettings) -> ForwardRequest[src]

Initializes the builder pattern for a Geolocation API query with the required, non-optional parameters.

Arguments:

  • key ‧ Your application's Google Cloud API key.

impl<'a> ForwardRequest<'a>[src]

pub fn validate(&mut self) -> Result<&'a mut ForwardRequest, Error>[src]

Ensures the built query is valid. This function checks the combination of parameters to ensure that they make sense together and that Google Maps Geocoding API will accept them - i.e. require an address or components to be specified. This function does not check parameter values for validity - i.e. it will not Latitudes/Longitudes are valid and well-formed.

Arguments:

This method accepts no arguments.

impl<'a> ForwardRequest<'a>[src]

pub fn with_address(&'a mut self, address: &str) -> &'a mut ForwardRequest[src]

Specifies the street address to geocode.

Arguments:

  • address - The street address that you want to geocode, in the format used by the national postal service of the country concerned. Additional address elements such as business names and unit, suite or floor numbers should be avoided. Please refer to the FAQ for additional guidance.

Example:

.with_address(String::from(
    "1313 Disneyland Dr, Anaheim, CA 92802, United States"
))

impl<'a> ForwardRequest<'a>[src]

pub fn with_bounds(&'a mut self, bounds: Bounds) -> &'a mut ForwardRequest[src]

Specifies a bounding box for biasing results.

Arguments:

  • bounds - The bounding box of the viewport within which to bias geocode results more prominently. This parameter will only influence, not fully restrict, results from the geocoder.

Description

Viewport Biasing

In a Geocoding request, you can instruct the Geocoding service to prefer results within a given viewport (expressed as a bounding box). You do so within the request URL by setting the bounds parameter. Note that biasing only prefers results within the bounds; if more relevant results exist outside of these bounds, they may be included.

The bounds parameter defines the latitude/longitude coordinates of the southwest and northeast corners of this bounding box.

For example, a geocode for "Winnetka" generally returns this suburb of Chicago. However, adding a bounds argument defining a bounding box for the San Fernando Valley of Los Angeles results in this geocode returning the neighborhood named "Winnetka" in that location.

Example:

  • Specify bounding box for search area:
.with_bounds(Bounds {
    southwest: LatLng::try_from(dec!(51.503_111_7), dec!(-0.129_150_3))?,
    northeast: LatLng::try_from(dec!(51.503_440_5), dec!(-0.126_003_2))?,
})

impl<'a> ForwardRequest<'a>[src]

pub fn with_component(
    &'a mut self,
    component: Component
) -> &'a mut ForwardRequest
[src]

Restricts the results from the geocoder to the specified component type(s).

Arguments:

  • component - A single component filter of Component type.

Description:

Component Filtering

In a Geocoding response, the Geocoding API can return address results restricted to a specific area. You can specify the restriction using the components filter. Filter values support the same methods of spelling correction and partial matching as other Geocoding requests. If the geocoder finds a partial match for a component filter, the response will contain a partial_match field.

The components that can be filtered include:

  • Component::Route matches the long or short name of a route.

  • Component::Locality matches against locality and sublocality types.

  • Component::AdministrativeArea matches all the administrative_area levels.

Notes about component filtering:

  • If the request contains multiple component filters, the API evaluates them as an AND, not an OR. For example, if the request includes multiple countries components=country:GB|country:AU, the API looks for locations where country=GB AND country=AU, and returns ZERO_RESULTS.

  • Results are consistent with Google Maps, which occasionally yields unexpected ZERO_RESULTS responses. Using Place Autocomplete may provide better results in some use cases. To learn more, see this FAQ.

  • For each address component, either specify it in the address parameter or in a components filter, but not both. Specifying the same values in both may result in ZERO_RESULTS.

Examples:

  • A single component filter. This example restricts results to Toronto:
.with_component(GeocodingComponent::Locality(String::from("Toronto")))
  • Multiple component filters may be stacked together. This example restricts results to a street in a city:
.with_component(GeocodingComponent::Route(String::from("Downing Street")))
.with_component(GeocodingComponent::Locality(String::from("London"))))

pub fn with_components(
    &'a mut self,
    components_slice: &[Component]
) -> &'a mut ForwardRequest
[src]

Restricts the results from the geocoder to the specified component type(s).

Example:

  • Alternatively, multiple component filters may be passed in a single method call by passing a Vec. This example restricts results to a street in a city:
.with_components(&vec![
    GeocodingComponent::Route(String::from("Downing Street")),
    GeocodingComponent::Locality(String::from("London")),
])

impl<'a> ForwardRequest<'a>[src]

pub fn with_language(&'a mut self, language: Language) -> &'a mut ForwardRequest[src]

Specifies the language in which to return results.

Arguments:

  • language - The language in which to return results.

Description

  • 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 geocoder attempts to use the preferred language as specified in the Accept-Language header, or the native language of the domain from which the request is sent.

  • The geocoder 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 geocoder 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 and square respectively in Hungarian.

Example:

  • Set language for result:
.with_language(Language::French)

impl<'a> ForwardRequest<'a>[src]

pub fn with_region(&'a mut self, region: Region) -> &'a mut ForwardRequest[src]

Specifies the region bias.

Arguments:

  • region ‧ The region to prefer in search results. This parameter will only influence, not fully restrict, results from the geocoder.

Description

Region Biasing

In a Geocoding request, you can instruct the Geocoding service to return results biased to a particular region by using the region parameter.

Geocoding results can be biased for every domain in which the main Google Maps application is officially launched. Note that biasing only prefers results for a specific domain; if more relevant results exist outside of this domain, they may be included.

For example, a directions request for "Toledo" to "Madrid" returns appropriate results when region is set to Region::Spain and "Toledo" is then interpreted as the Spanish city. A directions request for "Toledo" to "Madrid" sent without a region parameter does not return results, because "Toledo" is interpreted as the city in Ohio and not Spain.

Example:

  • Bias region to Canada:
.with_region(Region::Canada)

Trait Implementations

impl<'a> Debug for ForwardRequest<'a>[src]

impl<'a> Eq for ForwardRequest<'a>[src]

impl<'a> Ord for ForwardRequest<'a>[src]

impl<'a> PartialEq<ForwardRequest<'a>> for ForwardRequest<'a>[src]

impl<'a> PartialOrd<ForwardRequest<'a>> for ForwardRequest<'a>[src]

impl<'a> StructuralEq for ForwardRequest<'a>[src]

impl<'a> StructuralPartialEq for ForwardRequest<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for ForwardRequest<'a>

impl<'a> Send for ForwardRequest<'a>

impl<'a> Sync for ForwardRequest<'a>

impl<'a> Unpin for ForwardRequest<'a>

impl<'a> !UnwindSafe for ForwardRequest<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,