如何使用MapQuest.js获得路线距离?

发布于 2025-02-11 01:11:29 字数 488 浏览 2 评论 0 原文

我正在编写一个代码以找到最佳路由。我正在使用L.mapquest,并且在传单上获得路线图。但是,我需要这样的路线的距离和时间,但我不知道如何做到这一点。有人可以帮我吗?

以下是一个代码:

function findRouteForWaypoints(event){
    event.preventDefault();
    L.mapquest.key = config.MY_API_TOKEN;

    var dir = L.mapquest.directions().route({
      start: ''.concat(startPointLatitude,',',startPointLongitude),
      end: ''.concat(endPointLatitude,',',endPointLongitude),
      waypoints: binWaypoints,
      optimizeWaypoints: true
    })
}

I am writing a code to find the optimum route. I am using L.mapquest and I am getting the route plot on leaflet. However, I need the distance and time of such route but I can't figure out how to do this. Can someone help me, please?

The following is a piece of code:

function findRouteForWaypoints(event){
    event.preventDefault();
    L.mapquest.key = config.MY_API_TOKEN;

    var dir = L.mapquest.directions().route({
      start: ''.concat(startPointLatitude,',',startPointLongitude),
      end: ''.concat(endPointLatitude,',',endPointLongitude),
      waypoints: binWaypoints,
      optimizeWaypoints: true
    })
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我恋#小黄人 2025-02-18 01:11:29

您可以使用路由回调函数获取其他路由参数(例如距离)。

You can use the route callback function to get other route parameters like distance.
https://developer.mapquest.com/documentation/mapquest-js/v1.3/l-mapquest-directions-route/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文