[null,null,["最后更新时间 (UTC):2025-06-20。"],[[["\u003cp\u003eWhen calling methods to compute routes or route matrices, you must specify the desired information using a response field mask to avoid errors and unnecessary charges.\u003c/p\u003e\n"],["\u003cp\u003eResponse field masks are comma-separated lists of field paths, starting from the top-level response message and using dot-separated paths to specific fields.\u003c/p\u003e\n"],["\u003cp\u003eUsing field masks is a best practice as it reduces processing time, response size, and costs by ensuring only necessary data is requested.\u003c/p\u003e\n"],["\u003cp\u003eYou can determine the required field masks by requesting all fields during development (using \u003ccode\u003e*\u003c/code\u003e), examining the response hierarchy, and constructing paths based on the field hierarchy.\u003c/p\u003e\n"],["\u003cp\u003eTo obtain route tokens for use in the Navigation SDK, set specific parameters, ensure no \u003ccode\u003evia\u003c/code\u003e waypoints, and include \u003ccode\u003eroutes.routeToken\u003c/code\u003e in the field mask.\u003c/p\u003e\n"]]],["When requesting route information, you must specify a **response field mask** to define which data fields to return. This is done via the `$fields`/`fields` URL parameter or the `X-Goog-FieldMask` header. The field mask is a comma-separated list of paths (e.g., `routes.legs.distanceMeters,routes.legs.steps.duration`), starting from the top-level response and using dot-notation to access nested fields. Use the API references to find available fields. Avoid requesting all fields with `*`, because that lead to higher cost and latency.\n"],null,["**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\n\u003cbr /\u003e\n\nChoose fields to return\n=======================\n\nWhen you request a route or route matrix, you must use a field mask to specify what information\nthe response should return. There is no default list of returned fields. If you don't specify a field mask, the methods return an error.\n\nUsing a field mask also ensures that you don't request\nunnecessary data, which in turn helps with response latency and avoids returning information your system doesn't need.\n\nYou specify the list of the fields you need in a **response field mask** . You then pass\nthe response field mask to either method by using the URL parameter `$fields` or\n`fields`, or by using the HTTP or gRPC header `X-Goog-FieldMask`.\n\nFor more information about URL parameters, see\n[System Parameters](https://cloud.google.com/apis/docs/system-parameters).\n\nDefine a response field mask\n----------------------------\n\nThe response field mask is a comma-separated list of paths, where each\npath specifies a unique field in the response message.\nThe path starts from the top-level response message and uses a\ndot-separated path to the specified field.\n\nConstruct and specify a field path as follows:\n\n1. **Find the fields that contain the information you need** . For details, see [Field References](#field-ref).\n2. **Determine the paths for the fields you need and construct the field masks for them** : For details, see [Determine what field mask you want to use](#determine-field-mask).\n3. **Combine the field masks for all of the fields you need** , separating the field masks with commas. For example, to request the `distanceMeters` for the route leg, plus the duration for each route leg step, enter them both, separated by a comma, with no spaces:\n\n ```\n routes.legs.distanceMeters,routes.legs.steps.duration\n ```\n4. **Send the field mask with your API request** . For example, in a curl request, you would specify the field mask with `-H` and `X-Goog-FieldMask`:\n\n ```\n -H X-Goog-FieldMask: routes.legs.distanceMeters,routes.legs.steps.duration\n ```\n\nFor examples and more details, see the following sections.\n\n### Field References\n\nTo see the fields that you can request in a response through field masks, refer to the Routes API Compute Routes or Compute Route Matrix references linked in the following list. Specify fields in camel case as shown in the reference. For example, `routePreference`.\n| In contrast, you must enter parameter **values** as shown. For example, for `routingPreference`, you must enter `TRAFFIC_AWARE`.\n\nThese references include the fields that are available; however, you need to refer to the hierarchy of the fields to determine the full field mask path. For details on getting the hierarchy of the fields, see [Determine what field mask you want to use](#determine-field-mask).\n\n- **Compute route field mask**\n - REST: Specifies the fields of the [Route](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes#Route) object in the response to return, prefixed by `routes.`, for example, `routes.distanceMeters`.\n - gRPC: Specifies the fields of the [Route](/maps/documentation/routes/reference/rpc/google.maps.routing.v2#route) object in the response to return.\n- **Compute Route Matrix field masks**\n - REST: Specifies the fields of the [Response body](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRouteMatrix#response-body) to return.\n - gRPC: Specifies the fields of the [RouteMatrixElement](/maps/documentation/routes/reference/rpc/google.maps.routing.v2#routematrixelement) object in the response to return.\n\n### Determine what field masks to use\n\nHere's how you can determine which fields you want to use, and construct the field masks for them:\n\n1. **Request all fields** using a field mask of `*`. **Caution:** While you can use this wildcard field mask while in development to determine what fields you need, don't use it in production. Requesting all fields in production results in higher costs and longer response times. Your cost may also increase unexpectedly as more advanced features are added, since this field mask will automatically include them. Instead, request only the fields you need to minimize your costs and request response time.\n2. **Look at the hierarchy of the fields** in the response for the fields you want.\n3. **Construct your field masks** using the hierarchy of the fields shown in the previous step, using this format:\n\n ```\n topLevelField[.secondLevelField][.thirdLevelField][...]\n ```\n | **Note:** Don't use spaces anywhere in the list of field paths.\n\nFor example, for this partial response from a route: \n\n```json\n\"routes\": [\n {\n \"legs\": [\n { \"steps\": [\n {\"distanceMeters\": 119},\n {\"distanceMeters\": 41} ]\n }\n ],\n \"distanceMeters\": 160\n }\n]\n```\n\nIf you want to return only the `distanceMeters` field for the route leg; that is, the last `distanceMeters` in the preceding sample, your field mask is as follows: \n\n```\nroutes.legs.distanceMeters\n```\n\nIf you want instead want to return the `distanceMeters` field for each step of the route leg; that is, the `distanceMeters` under `steps` in the preceding sample, your field mask is as follows: \n\n```\nroutes.legs.steps.distanceMeters\n```\n\nIf you want to return both, with the result above, your field mask is as follows: \n\n```\nroutes.legs.distanceMeters,routes.legs.steps.distanceMeters\n```\n\nExample field mask paths\n------------------------\n\nThis section contains more examples on how to specify a field path as part of a response field mask in REST and gRPC calls.\n\n### REST call to `computeRoutes`\n\nIn the first example, you use a REST call to the\n[`computeRoutes`](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes) method to calculate\na route. In this example, in the header, you specify field masks to return the route `distanceMeters` and `duration` fields in the response. Remember to prefix the field name by `routes`. \n\n```restructuredtext\nX-Goog-FieldMask: routes.distanceMeters,routes.duration\n```\n\n### REST call to `computeRouteMatrix`\n\nFor the REST [`computeRouteMatrix`](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRouteMatrix)\nmethod used to compute a route matrix, in the header, specify to return\n`originIndex`, `destinationIndex`, and `duration` for each combination of origin\nand destination: \n\n```restructuredtext\nX-Goog-FieldMask: originIndex,destinationIndex,duration\n```\n\n### gRPC call\n\nFor gRPC, set a variable containing the response field mask. You can then pass that variable to the request. \n\n```gdscript\nconst (\n fieldMask = \"routes.distanceMeters,routes.duration,routes.polyline.encodedPolyline\"\n)\n```\n\nField path considerations\n-------------------------\n\nInclude only the fields that you require in the response to return just the\nfields that you need:\n\n- **Decreases processing times**, so your results are returned with a lower latency.\n- **Ensures stable latency performance**. If you select all fields, or if you select all fields at the top level, you might experience performance degradation when new fields are added and then are automatically included in your response.\n- **Results in a smaller response size**, which translates into higher network throughput.\n- **Ensures that you don't request unnecessary data**, which helps to avoid unnecessary processing time and billed charges.\n\n| **Note:** When a response message is parsed, and a field in the response message contains its default value, the field may be omitted from the response even if you specified it in the response field mask. For more information, see the [Language Guide (proto3)](https://developers.google.com/protocol-buffers/docs/proto3#default). For example, when you compute a route matrix, the `distanceMeters` field of the response can contain a value of 0, its default value. Because 0 is the default value of `distanceMeters`, it is omitted from the response.\n\nFor more details on constructing a field mask, see the\n[field_mask.proto](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto)."]]