با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
توسعه دهندگان منطقه اقتصادی اروپا (EEA).
ایستگاه های بین راهی، مکان هایی در بین مبدا و مقصد هستند که می خواهید مسیر از آنها عبور کند. یک ایستگاه میانی می تواند یک توقف باشد یا می توانید آن را به عنوان مکانی برای عبور مشخص کنید. برای مثالی از یک ایستگاه برای توقف، به تنظیم توقف در طول یک مسیر مراجعه کنید. برای مثالی از یک نقطه عبور برای عبور، نقطه را برای یک مسیر برای عبور تنظیم کنید .
از ویژگی آرایه intermediates متد computeRoutes (REST) یا روش ComputeRoutes (gRPC) برای تعریف حداکثر 25 نقطه میانی استفاده کنید.
برای هر نقطه میانی در درخواست، شی مسیر (REST) یا شی مسیر (gRPC) در پاسخ یک ورودی به آرایه legs اضافه میکند تا جزئیات مربوط به آن مرحله از سفر را ارائه کند.
هر پا از یک مسیر با یک شی RouteLeg (REST) یا RouteLeg (gRPC) نشان داده می شود. با استفاده از ماسک فیلد پاسخ، فیلدهای RouteLeg را کنترل کنید.
مثال - یک نقطه بین راه را تنظیم کنید
مثال زیر از ویژگی آرایه intermediates برای اضافه کردن یک ایستگاه بین راهی به بدنه درخواست POST یک مسیر استفاده می کند.
این مثال از یک ماسک فیلد پاسخ در هدر X-Goog-FieldMask استفاده می کند که مشخص می کند فیلدهای زیر را در پاسخ برگرداند:
تاریخ آخرین بهروزرسانی 2025-07-22 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-22 بهوقت ساعت هماهنگ جهانی."],[[["\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```"]]