【发布时间】:2016-03-09 17:48:41
【问题描述】:
我实际上正在使用 Leaflet Routing Machine 为一个学校项目工作,并且对 totalTime 方法有疑问。
var map = L.map('map');
L.tileLayer('', {
attribution: ''
}).addTo(map);
L.Routing.control({
waypoints: [
L.latLng(45.7979, 4.7178),
L.latLng(45.5221, 4.8101),
L.latLng(45.42, 4.35)
],
routeWhileDragging: true,
language: 'fr'
}).addTo(map);
L.Routing.control({
waypoints: [
L.latLng(44.7979, 4.7178),
L.latLng(45.42, 4.35)
],
routeWhileDragging: true,
language: 'fr'
}).addTo(map);
window.alert(routes[0].summary.totalTime());
但是 JS 控制台告诉我 routes[] 没有定义。
有什么问题吗?我们应该使用 routes[] 以外的其他东西吗?
【问题讨论】:
-
你,呃,没有在这段代码的任何地方定义
routes。 -
当然,但我也想调用方法
totalTime。 liedman.net/leaflet-routing-machine/api/#irouter我找到了这个话题:stackoverflow.com/questions/26570980/…所以我试了一下。
标签: javascript routing routes leaflet