Overview Stay organized with collections Save and categorize content based on your preferences.
The Routes Library, Maps JavaScript API includes theRoute
andRouteMatrix
classes, which replace the legacyDirectionsService
andDistanceMatrixService
objects.
Route
class

TheRoute
class provides thecomputeRoutes()
method, which returns the ideal route between two locations. Provide directions with real-time traffic for transit, biking, driving, 2-wheel motorized vehicles, or walking between multiple locations.
RouteMatrix
class

TheRouteMatrix
class returns distances and travel times for a matrix of routes between different origin and destination locations. Calculate travel times and distances for multiple destinations for up to 625 route elements.
Next steps
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-02 UTC.