Enum google_maps::directions::request::location::Location
source · pub enum Location {
Address(String),
LatLng(LatLng),
PlaceId(String),
}
Expand description
Used to specify the address, latitude/longitude, or place ID for the origin and destination.
Variants§
Address(String)
If you pass an address, the Directions service geocodes the string and converts it to a latitude/longitude coordinate to calculate directions. This coordinate may be different from that returned by the Geocoding API, for example a building entrance rather than its center.
LatLng(LatLng)
If you pass coordinates, they are used unchanged to calculate directions.
PlaceId(String)
The place ID may only be specified if the request includes an API key or a Google Maps Platform Premium Plan client ID. You can retrieve place IDs from the Geocoding API and the Places API (including Place Autocomplete). For an example using place IDs from Place Autocomplete, see Place Autocomplete and Directions. For more about place IDs, see the Place ID overview.
Implementations§
source§impl Location
impl Location
sourcepub fn from_address(address: impl Into<String>) -> Self
pub fn from_address(address: impl Into<String>) -> Self
If you pass an address, the Directions service geocodes the string and converts it to a latitude/longitude coordinate to calculate directions. This coordinate may be different from that returned by the Geocoding API, for example a building entrance rather than its center.
source§impl Location
impl Location
sourcepub fn from_place_id(place_id: impl Into<String>) -> Self
pub fn from_place_id(place_id: impl Into<String>) -> Self
The place ID may only be specified if the request includes an API key or a Google Maps Platform Premium Plan client ID. You can retrieve place IDs from the Geocoding API and the Places API (including Place Autocomplete). For an example using place IDs from Place Autocomplete, see Place Autocomplete and Directions. For more about place IDs, see the Place ID overview.
source§impl Location
impl Location
sourcepub fn try_from_dec(
latitude: Decimal,
longitude: Decimal,
) -> Result<Self, GoogleMapsError>
pub fn try_from_dec( latitude: Decimal, longitude: Decimal, ) -> Result<Self, GoogleMapsError>
Takes individual latitude & longitude Decimal
coordinates and
converts them into a Location
structure. If either the latitude
(-90.0 to +90.0) or longitude (-180.0 to +180.0) are out of range, this
function will return an error.
source§impl Location
impl Location
sourcepub fn try_from_f32(
latitude: f32,
longitude: f32,
) -> Result<Self, GoogleMapsError>
pub fn try_from_f32( latitude: f32, longitude: f32, ) -> Result<Self, GoogleMapsError>
Takes individual latitude & longitude f32
coordinates and
converts them into a Location
structure. If either the latitude
(-90.0 to +90.0) or longitude (-180.0 to +180.0) are out of range, this
function will return an error.
source§impl Location
impl Location
sourcepub fn try_from_f64(
latitude: f64,
longitude: f64,
) -> Result<Self, GoogleMapsError>
pub fn try_from_f64( latitude: f64, longitude: f64, ) -> Result<Self, GoogleMapsError>
Takes individual latitude & longitude f64
coordinates and
converts them into a Location
structure. If either the latitude
(-90.0 to +90.0) or longitude (-180.0 to +180.0) are out of range, this
function will return an error.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Location
impl<'de> Deserialize<'de> for Location
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Ord for Location
impl Ord for Location
source§impl PartialEq for Location
impl PartialEq for Location
source§impl PartialOrd for Location
impl PartialOrd for Location
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more