google_maps2/geocoding/forward/with_region.rs
1use crate::{geocoding::forward::ForwardRequest, types::Region};
2
3impl<'a> ForwardRequest<'a> {
4 /// Specifies the region bias.
5 ///
6 /// ## Arguments
7 ///
8 /// * `region` ‧ The region to prefer in search results. This parameter will
9 /// only influence, not fully restrict, results from the geocoder.
10 ///
11 /// ## Description
12 ///
13 /// [Region
14 /// Biasing](https://developers.google.com/maps/documentation/geocoding/intro#RegionCodes)
15 ///
16 /// In a Geocoding request, you can instruct the Geocoding service to return
17 /// results biased to a particular region by using the `region` parameter.
18 ///
19 /// Geocoding results can be biased for every domain in which the main
20 /// Google Maps application is officially launched. Note that biasing only
21 /// _prefers_ results for a specific domain; if more relevant results exist
22 /// outside of this domain, they may be included.
23 ///
24 /// For example, a directions request for "Toledo" to "Madrid" returns
25 /// appropriate results when `region` is set to `Region::Spain` and "Toledo"
26 /// is then interpreted as the Spanish city. A directions request for
27 /// "Toledo" to "Madrid" sent without a `region` parameter does not return
28 /// results, because "Toledo" is interpreted as the city in Ohio and not
29 /// Spain.
30 ///
31 /// ## Example
32 ///
33 /// * Bias region to Canada:
34 /// ```rust
35 /// .with_region(Region::Canada)
36 /// ```
37
38 pub fn with_region(&'a mut self, region: Region) -> &'a mut Self {
39 // Set region in ForwardRequest struct.
40 self.region = Some(region);
41 // Return modified ForwardRequest struct to caller.
42 self
43 } // fn
44} // impl