如何使用MapQuest.js获得路线距离?
我正在编写一个代码以找到最佳路由。我正在使用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
})
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用路由回调函数获取其他路由参数(例如距离)。
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/