1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
/// Used to specify pass throughs or stopovers at intermediate locations. #[derive(Clone, Debug)] pub enum Waypoint { /// 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. Address(String), /// If you pass coordinates, they are used unchanged to calculate /// directions. LatLng { /// Latitude lat: f32, /// Longitude lng: f32 }, /// 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](https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-directions). /// For more about place IDs, see the [Place ID overview](https://developers.google.com/places/place-id). PlaceId(String), /// Alternatively, you can supply an encoded set of points using the /// [Encoded Polyline Algorithm](https://developers.google.com/maps/documentation/utilities/polylinealgorithm). /// You will find an encoded set is useful for a large number of waypoints, /// because the URL is significantly shorter. All web services have a URL /// limit of 8192 characters. Polyline(String), } // enum impl From<&Waypoint> for String { /// Converts a `Waypoint` enum to a `String` that contains a /// [waypoint](https://developers.google.com/maps/documentation/directions/intro#Waypoints) /// value. fn from(waypoint: &Waypoint) -> String { match waypoint { Waypoint::Address(address) => address.clone(), Waypoint::LatLng { lat, lng } => format!("{:.7},{:.7}", lat, lng), Waypoint::PlaceId(place_id) => format!("place_id:{}", place_id), Waypoint::Polyline(polyline) => format!("enc:{}:", polyline), } // match } // fn } // impl