Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Deweloperzy z Europejskiego Obszaru Gospodarczego (EOG)
Punkty pośrednie to lokalizacje między miejscem początkowym a docelowym, przez które ma przebiegać trasa. Punkt pośredni może być przystankiem lub możesz go określić jako lokalizację, przez którą chcesz przejechać. Przykład punktu trasy dla przystanku znajdziesz w artykule Ustawianie przystanku na trasie. Przykład punktu pośredniego, przez który ma przechodzić trasa, znajdziesz w sekcji Ustawianie punktu, przez który ma przechodzić trasa.
Użyj właściwości tablicy intermediates metody computeRoutes (REST) lub metody ComputeRoutes (gRPC), aby zdefiniować maksymalnie 25 pośrednich punktów na trasie.
W przypadku każdego pośredniego punktu trasy w żądaniu obiekt Route (REST) lub obiekt Route (gRPC) w odpowiedzi dodaje wpis do tablicy legs, aby podać szczegóły tego etapu podróży.
Każdy etap trasy jest reprezentowany przez obiekt RouteLeg (REST) lub RouteLeg (gRPC).
Określ, które pola RouteLeg mają zostać zwrócone, używając maski pola odpowiedzi.
Przykład – ustawianie pośredniego punktu trasy
W tym przykładzie użyto właściwości tablicy intermediates, aby dodać do treści żądania POST dotyczącego trasy pojedynczy pośredni punkt trasy.
W tym przykładzie używamy maski pola odpowiedzi w nagłówku X-Goog-FieldMask, która określa, że w odpowiedzi mają być zwracane te pola:
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 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```"]]