Allow steps to be nested under google.maps.DirectionsLeg (#37963)

This commit is contained in:
Ryan Blackman
2019-08-29 18:05:09 -07:00
committed by Ron Buckton
parent 0d45a2d5af
commit 846d821ff5
2 changed files with 36 additions and 2 deletions
+28
View File
@@ -793,3 +793,31 @@ const directionsWaypointLocationPlace: google.maps.DirectionsWaypoint = {
const directionsWaypointStopover: google.maps.DirectionsWaypoint = {
stopover: true,
};
/***** google.maps.DirectionsService *****/
let directionsService = new google.maps.DirectionsService();
directionsService.route({
avoidFerries: true,
avoidHighways: true,
avoidTolls: true,
destination: 'destination',
origin: 'origin',
provideRouteAlternatives: true,
transitOptions: {
arrivalTime: new Date(),
departureTime: new Date(),
modes: [
google.maps.TransitMode.BUS,
google.maps.TransitMode.RAIL
],
routingPreference: google.maps.TransitRoutePreference.FEWER_TRANSFERS
},
travelMode: google.maps.TravelMode.TRANSIT,
unitSystem: google.maps.UnitSystem.IMPERIAL
}, (result: google.maps.DirectionsResult, status: google.maps.DirectionsStatus) => {
const routes = result.routes; // $ExpectType DirectionsRoute[]
const legs = routes[0].legs; // $ExpectType DirectionsLeg[]
const steps = legs[0].steps; // $ExpectType DirectionsStep[]
steps[0].steps; // $ExpectType BaseDirectionsStep[]
});
+8 -2
View File
@@ -1977,18 +1977,24 @@ declare namespace google.maps {
via_waypoints: LatLng[];
}
interface DirectionsStep {
interface BaseDirectionsStep {
distance: Distance;
duration: Duration;
end_location: LatLng;
instructions: string;
path: LatLng[];
start_location: LatLng;
steps: DirectionsStep;
transit: TransitDetails;
travel_mode: TravelMode;
}
interface DirectionsStep extends BaseDirectionsStep {
/**
* This field will only be available if travel_mode is set to TRANSIT.
*/
steps: BaseDirectionsStep[];
}
interface Distance {
text: string;
value: number;