DirectionsService component calculates directions between locations using the Google Maps Directions API.
Import
Usage
Props
The directions request configuration.Required fields:
origin: Starting point (can be a string address, LatLng, or Place ID)destination: End point (can be a string address, LatLng, or Place ID)travelMode: Mode of transportation (DRIVING, WALKING, BICYCLING, or TRANSIT)
waypoints: Array of intermediate stopsoptimizeWaypoints: Whether to optimize the order of waypointsprovideRouteAlternatives: Whether to return alternative routesavoidHighways: Whether to avoid highwaysavoidTolls: Whether to avoid tollsavoidFerries: Whether to avoid ferriesregion: The region code for biasing the resultsunitSystem: Unit system for distances (METRIC or IMPERIAL)
callback
(result: google.maps.DirectionsResult | null, status: google.maps.DirectionsStatus) => void
required
Callback function invoked when the directions request completes.Parameters:
result: The directions result object if successful, ornullif the request failedstatus: The status of the request (OK, NOT_FOUND, ZERO_RESULTS, etc.)
Callback invoked when the directions service instance has been created.Parameters:
directionsService: The directions service instance
Callback invoked when the component unmounts.Parameters:
directionsService: The directions service instance