A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/maps/documentation/routes_preferred/compute_route_matrix below:

Compute a Route Matrix | Google Maps Platform Routes Preferred API

Skip to main content Compute a Route Matrix

Stay organized with collections Save and categorize content based on your preferences.

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 Maps Platform Service Specific Terms. For more information, see the launch stage descriptions.

You can calculate the distance and duration of a route for multiple origins and destinations by using the ComputeRouteMatrix method of the Routes Preferred API. ComputeRouteMatrix supports both streaming gRPC calls and REST HTTP calls.

Given a list of origin and destination pairs, ComputeRouteMatrix calculates the distance and duration of a route starting at each origin and ending at each destination. Each element of the stream corresponds to the information for a single route.

The ComputeRouteMatrix method has several advantages over the Distance Matrix Service:

Enable the ComputeRouteMatrix method

Before you can use the ComputeRouteMatrix method in your code, you must enable it. For more information on enabling Routes Preferred API methods, see Getting Started.

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 in the Google Cloud Console, or by calling the Google Cloud Support Hotline. Use the ComputeRouteMatrix method

The ComputeRouteMatrix method is available through the Routes Preferred v1 endpoint.

See the following documentation for more detailed information:

gRPC: https://developers.google.com/maps/documentation/routes_preferred/reference/rpc/google.maps.routes.v1

REST: https://developers.google.com/maps/documentation/routes_preferred/reference/rest/v1/TopLevel/computeRouteMatrix

The following generic steps describe how to use gRPC to call the ComputeRouteMatrix method:

  1. Check out the necessary protobuffers from the googleapis repository:

    https://github.com/googleapis/googleapis/tree/master/google/maps/routes

    Note that some build systems, such as Go, may automatically do this for you.

  2. Using your preferred language and set of build tools, generate the relevant protobuffer code.

  3. Generate your request. Two required pieces of metadata must be sent with the request:

  4. Send your request to routespreferred.googleapis.com:443.You must use the TLS protocol.

For examples of using the ComputeRouteMatrix method, see Computing a Route Matrix (Beta) Examples.

One distinguishing feature of the ComputeRouteMatrix method is that error codes can be returned either for the entire stream or for individual elements. For example, the stream connection returns an error if the request is malformed (for example, it has zero origins). However, if an error applies to just a few elements of the stream (for example, setting an invalid Place ID for an origin), then only the elements affected by the error contain error codes.

The elements returned by the stream are not guaranteed to be returned in any order. Because of this, each element contains an origin_index and a destination_index. For the origins and destinations specified by the request, the route origin is equivalent to origins[origin_index] for a given element and the route destination is is equivalent to destinations[destination_index]. These arrays are zero-indexed. It is important to store the origin and destination list orders.

Calculating toll fees

For information on calculating toll fees, see Calculate toll fees.

For examples of calculating toll fees, see Computing a Route Matrix Examples.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-14 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["The `ComputeRouteMatrix` method in the Routes Preferred API calculates distances and durations for multiple origin-destination pairs, offering advantages like streaming results and traffic calculation options."],["It's necessary to enable the `ComputeRouteMatrix` method and understand quota limits before implementation, ensuring compliance with Google Maps Platform terms."],["The method can be accessed through gRPC or REST, with specific steps outlined for using gRPC, including generating protobuffer code and configuring requests."],["Responses include `origin_index` and `destination_index` to correlate results with input data since the order of elements is not guaranteed."],["Toll fee calculation functionality is available within `ComputeRouteMatrix`, allowing developers to incorporate toll costs into route planning."]]],["The `ComputeRouteMatrix` method of the Routes Preferred API calculates route distance and duration for multiple origins and destinations via streaming gRPC or REST HTTP calls. It offers lower latency, fine-grained traffic options, higher availability, waypoint specifications, and toll information. To use it, enable the method, and send requests with API key and field mask. The method returns elements with `origin_index` and `destination_index`. Error codes can be returned for the entire stream or per individual element.\n"]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4