[−][src]Struct google_maps::geocoding::forward::ForwardRequest
Use this structure's methods to build your Forward Geocoding API request. Latitude/longitude lookup from address.
Methods
impl ForwardRequest
[src]
pub fn build(&mut self) -> Result<&mut ForwardRequest, Error>
[src]
Builds the query string for the Google Maps Geocoding API based on the input provided by the client.
impl ForwardRequest
[src]
pub fn execute(&mut self) -> Result<Response, Error>
[src]
Arguments:
This method accepts no arguments.
impl ForwardRequest
[src]
pub fn get(&self) -> Result<Response, Error>
[src]
Performs the HTTP get request and returns the response to the caller.
Arguments:
This method accepts no arguments.
impl ForwardRequest
[src]
pub fn new(key: String) -> 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 ForwardRequest
[src]
pub fn validate(&mut self) -> Result<&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. it will not allow both a Positional Request and a Sampled Path Request in the same query. This function does not check parameter values for validity - i.e. it will not ensure Polylines or Latitudes/Longitudes are valid and well-formed.
impl ForwardRequest
[src]
pub fn with_address(&mut self, address: &str) -> &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 ForwardRequest
[src]
pub fn with_bounds(&mut self, bounds: Bounds) -> &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
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 { lat: 51.5031117, lng: -0.1291503 }, northeast: LatLng { lat: 51.5034405, lng: -0.1260032 }, })
impl ForwardRequest
[src]
pub fn with_component(&mut self, component: Component) -> &mut ForwardRequest
[src]
Restricts the results from the geocoder to the specified component type(s).
Arguments:
component
- A single component filter ofComponent
type.
Description:
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 againstlocality
andsublocality
types. -
Component::AdministrativeArea
matches all theadministrative_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 returnsZERO_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 acomponents
filter, but not both. Specifying the same values in both may result inZERO_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(
&mut self,
components_slice: &[Component]
) -> &mut ForwardRequest
[src]
&mut self,
components_slice: &[Component]
) -> &mut ForwardRequest
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 ForwardRequest
[src]
pub fn with_language(&mut self, language: Language) -> &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 theAccept-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 ForwardRequest
[src]
pub fn with_region(&mut self, region: Region) -> &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
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 Clone for ForwardRequest
[src]
fn clone(&self) -> ForwardRequest
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ForwardRequest
[src]
Auto Trait Implementations
impl RefUnwindSafe for ForwardRequest
impl Send for ForwardRequest
impl Sync for ForwardRequest
impl Unpin for ForwardRequest
impl UnwindSafe for ForwardRequest
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,