概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Maps JavaScript API 的 Routes 库包含 Route
和 RouteMatrix
类,这两个类取代了旧版 DirectionsService
和 DistanceMatrixService
对象。
Route
类
Route
类提供 computeRoutes()
方法,该方法会返回两个位置之间的理想路线。提供多个地点之间的公交、骑行、驾车、两轮机动车或步行路线及实时路况。
RouteMatrix
类
RouteMatrix
类可返回不同出发地和目的地位置之间的一系列路线的距离和行程时间。支持计算多个目的地之间的行程时间与距离,最多可包含 625 个路线元素。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-27。
[null,null,["最后更新时间 (UTC):2025-08-27。"],[],[],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\nThe Routes Library, Maps JavaScript API includes the `Route` and `RouteMatrix`\nclasses, which replace the legacy `DirectionsService` and `DistanceMatrixService`\nobjects.\n\n`Route` class\n\nThe `Route` class provides the `computeRoutes()` method, which returns\nthe ideal route between two locations. Provide directions with real-time traffic for transit,\nbiking, driving, 2-wheel motorized vehicles, or walking between multiple locations.\n\n- [Route class overview](/maps/documentation/javascript/routes/route-class-overview)\n- [Migrate to the new `Route` class](/maps/documentation/javascript/routes/routes-js-migration)\n- [Try the Routes library demo](/maps/documentation/javascript/routes/demo)\n\n`RouteMatrix` class\n\nThe `RouteMatrix` class returns distances and travel times for a matrix of routes\nbetween different origin and destination locations. Calculate travel times and distances for\nmultiple destinations for up to 625 route elements.\n\n- [Route matrix class overview](/maps/documentation/javascript/routes/route-matrix-class-overview)\n- [Migrate to the new `RouteMatrix` class](/maps/documentation/javascript/routes/route-matrix-js-migration)\n\nNext steps\n\n- [Get started](/maps/documentation/javascript/routes/start)"]]