**European Economic Area (EEA) developers**

> [!NOTE]
> 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](https://developers.google.com/maps/comms/eea/faq.md.txt).

The Routes Library, Maps JavaScript API includes the
[`Route`](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Route)
and
[`RouteMatrix`](https://developers.google.com/maps/documentation/javascript/reference/route-matrix.md.txt#RouteMatrix)
classes, which replace the legacy
[`DirectionsService`](https://developers.google.com/maps/documentation/javascript/reference/directions.md.txt#DirectionsService)
and
[`DistanceMatrixService`](https://developers.google.com/maps/documentation/javascript/reference/distance-matrix.md.txt#DistanceMatrixService)
objects. Load the library in your web application with
[`google.maps.importLibrary("routes")`](https://developers.google.com/maps/documentation/javascript/reference/top-level.md.txt#google.maps.importLibrary)
(see [Use
client-side SDKs](https://developers.google.com/maps/api-security-best-practices#use-client-side-sdks) for why browser applications should use this library
instead of calling the `https://routes.googleapis.com` web
service directly).

## `Route` class

![Directions on a map.](https://developers.google.com/static/maps/documentation/javascript/routes/images/routes_api_hero.png)

The [`Route`](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Route)
class provides the
[`computeRoutes()`](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Route.computeRoutes)
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.

- [Route class overview](https://developers.google.com/maps/documentation/javascript/routes/route-class-overview.md.txt)
- [Migrate to the new `Route` class](https://developers.google.com/maps/documentation/javascript/routes/routes-js-migration.md.txt)
- [Try the Routes library demo](https://developers.google.com/maps/documentation/javascript/routes/demo.md.txt)

## `RouteMatrix` class

![Distance matrix on a map.](https://developers.google.com/static/maps/documentation/javascript/routes/images/distanceMatrix_hero_image.png)

The `RouteMatrix` 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.

- [Route matrix class overview](https://developers.google.com/maps/documentation/javascript/routes/route-matrix-class-overview.md.txt)
- [Migrate to the new `RouteMatrix` class](https://developers.google.com/maps/documentation/javascript/routes/route-matrix-js-migration.md.txt)

## Choose a class for your use case

- **Route planning with multiple stops:** Use [`Route.computeRoutes()`](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Route.computeRoutes). It supports [intermediate waypoints](https://developers.google.com/maps/documentation/javascript/routes/intermediate-waypoints.md.txt), [stop optimization](https://developers.google.com/maps/documentation/javascript/routes/optimize-stops.md.txt), [alternative routes](https://developers.google.com/maps/documentation/javascript/routes/get-alternative-routes.md.txt), and [toll estimates](https://developers.google.com/maps/documentation/javascript/routes/routes-tolls.md.txt). To draw the route on a 2D map, call [`createPolylines()`](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Route.createPolylines) and [`createWaypointAdvancedMarkers()`](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Route.createWaypointAdvancedMarkers). To render a route on a 3D map, use the [`Route3DElement`](https://developers.google.com/maps/documentation/javascript/reference/routes-elements.md.txt#Route3DElement) (`<gmp-route-3d>`) web component, or call [`create3DPolylines()`](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Route.create3DPolylines), [`createPopover()`](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Route.createPopover), and [`createWaypointMarkers()`](https://developers.google.com/maps/documentation/javascript/reference/route.md.txt#Route.createWaypointMarkers).
- **Dispatch and nearest-location matching:** Use [`RouteMatrix.computeRouteMatrix()`](https://developers.google.com/maps/documentation/javascript/reference/route-matrix.md.txt#RouteMatrix.computeRouteMatrix) to compare travel times and distances across several origins and destinations, up to 625 route elements. For example, assign the closest driver to a pickup or pick the nearest warehouse for a delivery.

## Next steps

- [Get started](https://developers.google.com/maps/documentation/javascript/routes/start.md.txt)