차량 공유 여행의 최적 경로를 결정할 때 가장 빠른 경로가 항상 최선의 선택은 아닙니다. 경로를 계획하는 것이 좋습니다.
Routes Preferred API를 사용하면 ComputeCustomRoutes 메서드를 사용하여 경로 목표를 지정하여 경로를 계획할 수 있습니다.
ComputeCustomRoutes 메서드는 운전자가 선택한 경로와 운전한 경로 간의 차이를 최소화하여 경로 규정 준수에도 도움이 될 수 있습니다.
Routes Preferred API와 Navigation SDK를 모두 사용하여 경로 계획의 이점을 최대한 활용하세요.
ComputeCustomRoutes 메서드 사용 설정
코드에서 ComputeCustomRoutes 메서드를 사용하려면 먼저 사용 설정해야 합니다. Routes Preferred API 메서드 사용 설정에 관한 자세한 내용은 시작하기를 참고하세요.
ComputeCustomRoutes 메서드 사용
ComputeCustomRoutes 메서드를 사용하려면 입력에 응답 필드 마스크를 지정해야 합니다. URL 매개변수 $fields 또는 fields를 사용하거나 HTTP/gRPC 헤더 X-Goog-FieldMask를 사용하여 응답 필드 마스크를 제공할 수 있습니다. 자세한 내용은 시스템 매개변수를 참고하세요.
필드 마스크 값은 쉼표로 구분된 필드 경로 목록입니다. 각 필드 경로는 메시지 계층 구조를 나타내는 필드 이름의 점으로 구분된 목록입니다.
필드 이름은 JSON 객체 키 또는 protobuf 필드 태그 이름입니다.
필드 경로는 최상위 응답 메시지 유형에서 시작하며, 선택적으로 하나 이상의 점과 다음 수준의 필드 이름이 뒤따릅니다. 일반적으로 필드 경로는 다음과 같은 방식으로 구성됩니다.
[null,null,["최종 업데이트: 2025-07-22(UTC)"],[[["\u003cp\u003eThe Routes Preferred API's \u003ccode\u003eComputeCustomRoutes\u003c/code\u003e method enables planning routes based on objectives beyond the fastest route, such as compliance or driver preferences.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eComputeCustomRoutes\u003c/code\u003e supports optimizing routes for \u003ccode\u003eDRIVE\u003c/code\u003e and \u003ccode\u003eTWO_WHEELER\u003c/code\u003e travel modes, but excludes intermediate waypoints and other travel modes.\u003c/p\u003e\n"],["\u003cp\u003eUsing the Routes Preferred API with the Navigation SDK provides the best route planning outcomes, though they can utilize separate cloud projects.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the \u003ccode\u003eComputeCustomRoutes\u003c/code\u003e method, enable it and verify your quota limits, requesting increases if necessary through Google Cloud Support.\u003c/p\u003e\n"],["\u003cp\u003eTo specify desired data in the response, use field masks with the \u003ccode\u003eComputeCustomRoutes\u003c/code\u003e method, selecting fields using dot-separated paths from the top-level response.\u003c/p\u003e\n"]]],["The Routes Preferred API's `ComputeCustomRoutes` method allows route planning by specifying a route objective and minimizing deviations from the operator's selected route. This method supports `DRIVE` and `TWO_WHEELER` travel modes, excluding `via` waypoints. To use it, enable the method and specify a response field mask via `$fields`, `fields`, or `X-Goog-FieldMask`. Quota limits should be monitored. Use alongside the Navigation SDK to maximize route planning benefits. Additionally, toll fees can be calculated using this API.\n"],null,["# Plan a Route\n\n\u003cbr /\u003e\n\n| This product or feature is in Preview (pre-GA). Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. Pre-GA Offerings are covered by the [Google\n| Maps Platform Service Specific Terms](https://cloud.google.com/maps-platform/terms/maps-service-terms). For more information, see the [launch stage\n| descriptions](/maps/launch-stages).\n\n\u003cbr /\u003e\n\nWhen you are determining the best route for a ridesharing trip, the\nfastest route may not always be the best option. You may want\nto plan your route.\n\nThe Routes Preferred API lets you plan a route by specifying\na route objective using the `ComputeCustomRoutes` method.\n\nThe `ComputeCustomRoutes` method can also help with route compliance by letting\nyou minimize the difference between the route selected by the operator and the\nroute driven.\n\nUse both the Routes Preferred API and the\n[Navigation SDK](https://developers.google.com/maps/documentation/navigation-sdk)\nto realize the full benefit of route planning.\n| **Note:** You do not have to use the same cloud project for the Routes Preferred API and the Navigation SDK.\n| **Note:** Unlike `ComputeRoutes` API, `ComputeCustomRoutes` only supports two travel modes, `DRIVE` (or the equivalent `TRAVEL_MODE_UNSPECIFIED`) and `TWO_WHEELER`. This method also does not support `via` intermediate waypoints. If you try to use other travel modes or `via` waypoints, the request fails. For more information about `via` waypoints, see [Routes Preferred API waypoints](/maps/documentation/routes_preferred/reference/rest/Shared.Types/Waypoint).\n\nEnable the ComputeCustomRoutes method\n-------------------------------------\n\nBefore you can use the `ComputeCustomRoutes` method in your code, you must\nenable it. For more information on enabling Routes Preferred API\nmethods, see [Getting Started](/maps/documentation/routes_preferred/get_started).\n| **Important:** Check your quota limits for Routes Preferred API methods. If you need to increase your quota limits, contact support by filing a case on the [Google Maps Platform support page](https://console.cloud.google.com/google/maps-apis/support) in the Google Cloud Console, or by calling the [Google Cloud Support Hotline](/maps/documentation/routes_preferred/support#support_hotline).\n\nUse the ComputeCustomRoutes method\n----------------------------------\n\nThe `ComputeCustomRoutes` method requires that you specify a response\nfield mask in the input. You can provide the response field mask by using\nthe URL parameter `$fields` or `fields`, or by using the HTTP/gRPC header\n`X-Goog-FieldMask`. For more information, see\n[System Parameters](https://cloud.google.com/apis/docs/system-parameters).\n\nThe field mask value is a comma-separated list of field paths. Each field path\nis a dot-separated list of field names that represent the message hierarchy.\nA field name is either the JSON object key, or the protobuf field tag name.\nThe field path starts from the top level response message type,\nand is optionally followed by one or more dots, and then the next level\nof field name. In general, field paths are constructed in the following way: \n\n```\ntopLevelField[.secondLevelField][.thirdLevelField][...]\n```\n\nA special case field mask is a wildcard \"\\*\", which selects all root-level\nfields.\n\nFor more information, see:\n\n- [**gRPC API reference**](/maps/documentation/routes_preferred/reference/rpc/google.maps.routes.v1)\n- [**REST API reference**](/maps/documentation/routes_preferred/reference/rest/v1/TopLevel/computeCustomRoutes)\n\nFor examples of using the `ComputeCustomRoutes` method, see\n[Computing a Custom Route (Beta) Examples](/maps/documentation/routes_preferred/custom_route_examples).\n\nCalculating toll fees\n---------------------\n\nFor information on calculating toll fees, see\n[Calculate toll fees](/maps/documentation/routes_preferred/calculate_toll_fees).\n\nFor examples of calculating toll fees, see\n[Computing a Custom Route Examples](/maps/documentation/routes_preferred/custom_route_examples#toll-fee-examples)."]]