Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Développeurs de l'Espace économique européen (EEE)
Les points de cheminement intermédiaires sont des lieux situés entre le point de départ et la destination que vous souhaitez traverser. Un point de cheminement intermédiaire peut être un arrêt ou un lieu de passage. Pour obtenir un exemple de point de repère pour un arrêt, consultez Définir un arrêt sur un itinéraire. Pour obtenir un exemple de point de cheminement à traverser, consultez Définir un point pour une route à traverser.
Utilisez la propriété de tableau intermediates de la méthode computeRoutes (REST) ou de la méthode ComputeRoutes (gRPC) pour définir jusqu'à 25 points de chemin intermédiaires.
Pour chaque point de repère intermédiaire de la requête, l'objet Route (REST) ou l'objet Route (gRPC) de la réponse ajoute une entrée au tableau legs pour fournir les détails de cette étape du trajet.
Chaque tronçon d'un itinéraire est représenté par un objet RouteLeg (REST) ou RouteLeg (gRPC).
Contrôlez les champs RouteLeg à renvoyer à l'aide du masque de champ de réponse.
Exemple : Définir un point de cheminement intermédiaire
L'exemple suivant utilise la propriété de tableau intermediates pour ajouter un seul point de chemin intermédiaire au corps de la requête POST d'un itinéraire.
Cet exemple utilise un masque de champ de réponse dans l'en-tête X-Goog-FieldMask qui spécifie de renvoyer les champs suivants dans la réponse :
routes.duration
routes.distanceMeters
routes.legs correspondant à l'ensemble de l'objet RouteLeg.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/22 (UTC).
[null,null,["Dernière mise à jour le 2025/07/22 (UTC)."],[[["\u003cp\u003eIntermediate waypoints allow you to specify locations between the origin and destination for a route to pass through or stop at.\u003c/p\u003e\n"],["\u003cp\u003eYou can define up to 25 intermediate waypoints using the \u003ccode\u003eintermediates\u003c/code\u003e property when computing routes, but requests with 11 or more are billed at a higher rate.\u003c/p\u003e\n"],["\u003cp\u003eThe response provides route details including legs, with each leg representing a segment of the journey between waypoints.\u003c/p\u003e\n"],["\u003cp\u003eEach leg within the route is further broken down into steps, providing detailed information about each segment of the journey.\u003c/p\u003e\n"]]],["Intermediate waypoints, placed between the origin and destination, guide the route. Use the `intermediates` array in the `computeRoutes` method to define up to 25 waypoints, with options for stops or pass-throughs. Each waypoint adds a `leg` to the route's details. Requests with 11-25 waypoints are billed at a higher rate. Each route `leg` can be specified with desired fields through a response field mask to return the `duration`, `distanceMeters`, and `legs`.\n"],null,["# Set intermediate waypoints\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nIntermediate waypoints are locations in between the origin and destination\nthat you want the route to go through. An intermediate waypoint can be a stop or\nyou can specify it as a location to pass through. For an example of a waypoint\nfor a stop, see [Set a stop along a route](/maps/documentation/routes/stop_over). For an example of a\nwaypoint to pass-through,\n[Set point for a route to pass-through](/maps/documentation/routes/pass-through).\n| **Note:** Intermediate waypoints are not supported in the Compute Route Matrix.\n\nUse the `intermediates` array property of the\n[computeRoutes](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes) method (REST) or the\n[ComputeRoutes](/maps/documentation/routes/reference/rpc/google.maps.routing.v2#google.maps.routing.v2.Routes.ComputeRoutes)\nmethod (gRPC), to define up to a maximum of 25 intermediate waypoints.\n| **Caution:** If you make requests using 11 or more intermediate waypoints (between 11 and 25), your requests are billed at a higher rate. [Learn more about billing](/maps/documentation/routes/usage-and-billing) for Routes API.\n\nFor each intermediate waypoint in the request, the\n[Route object](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes#route) (REST) or\n[Route object](/maps/documentation/routes/reference/rpc/google.maps.routing.v2#route) (gRPC) in the\nresponse adds an entry to the `legs` array to provide the details for\nthat leg of the journey.\n\nEach leg of a route is represented by a\n[RouteLeg](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes#routeleg) (REST) or\n[RouteLeg](/maps/documentation/routes/reference/rpc/google.maps.routing.v2#routeleg) (gRPC) object.\nControl which `RouteLeg` fields to return by using the\n[response field mask](/maps/documentation/routes/choose_fields).\n\nExample - Set an intermediate waypoint\n--------------------------------------\n\nThe following example uses the `intermediates` array property to add a single\nintermediate waypoint to the POST request body of a route.\n\nThis example uses a response field mask in the `X-Goog-FieldMask` header\nthat specifies to return the following fields in the response:\n\n- `routes.duration`\n- `routes.distanceMeters`\n- `routes.legs` corresponding to the entire `RouteLeg` object.\n\n```json\ncurl -X POST -d '{\n \"origin\":{\n \"location\":{\n \"latLng\":{\n \"latitude\": 37.419734,\n \"longitude\": -122.0827784\n }\n },\n \"sideOfRoad\": true\n },\n \"destination\":{\n \"location\":{\n \"latLng\":{\n \"latitude\": 37.417670,\n \"longitude\": -122.079595\n }\n }\n },\n \"intermediates\": [\n {\n \"location\":{\n \"latLng\":{\n \"latitude\": 37.419734,\n \"longitude\": -122.0807784\n }\n }\n }\n ],\n \"travelMode\": \"DRIVE\",\n \"routingPreference\": \"TRAFFIC_AWARE\",\n \"departureTime\": \"2022-10-15T15:01:23.045123456Z\",\n \"computeAlternativeRoutes\": false,\n \"routeModifiers\": {\n \"avoidTolls\": false,\n \"avoidHighways\": false,\n \"avoidFerries\": false\n },\n \"languageCode\": \"en-US\",\n \"units\": \"IMPERIAL\"\n}'\n-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: YOUR_API_KEY'\n-H 'X-Goog-FieldMask: routes.duration,routes.distanceMeters,routes.legs'\n'https://routes.googleapis.com/directions/v2:computeRoutes'\n```\n\nThe response from this call contains the `legs` array. Each step of the leg is\nrepresented by a\n[RouteLegStep](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes#routelegstep) (REST) or\n[RouteLegStep](/maps/documentation/routes/reference/rpc/google.maps.routing.v2#routelegstep) (gRPC) object. \n\n```json\n{\n \"routes\": [\n {\n \"legs\": [\n # First leg\n {\n \"distanceMeters\": 207,\n \"duration\": \"89s\",\n \"staticDuration\": \"89s\",\n \"polyline\": {\n \"encodedPolyline\": \"ipkcFjgchVd@@@cF]@@oCK?\"\n },\n \"startLocation\": {\n \"latLng\": {\n \"latitude\": 37.4197318,\n \"longitude\": -122.0826233\n }\n },\n \"endLocation\": {\n \"latLng\": {\n \"latitude\": 37.419734,\n \"longitude\": -122.08077919999998\n }\n },\n \"steps\": [ {\n \"distanceMeters\": 21,\n \"staticDuration\": \"6s\",\n \"polyline\": {\n \"encodedPolyline\": \"ipkcFjgchVd@@\"\n },\n \"startLocation\": {\n \"latLng\": {\n \"latitude\": 37.4197318,\n \"longitude\": -122.0826233\n }\n },\n \"endLocation\": {\n \"latLng\": {\n \"latitude\": 37.41954,\n \"longitude\": -122.08262750000002\n }\n }\n },\n ...\n },\n # Second leg\n {\n \"distanceMeters\": 598,\n \"duration\": \"159s\",\n \"staticDuration\": \"159s\",\n \"polyline\": {\n \"encodedPolyline\": \"ipkcFz{bhVh@??{@xPBP?J}E{E?\"\n },\n \"startLocation\": {\n \"latLng\": {\n \"latitude\": 37.419734,\n \"longitude\": -122.08077919999998\n }\n },\n \"endLocation\": {\n \"latLng\": {\n \"latitude\": 37.417616599999995,\n \"longitude\": -122.07938820000001\n }\n },\n \"steps\": [\n {\n ...\n```"]]