我使用mapbox方向在两点之间绘制路线。我需要检查这条路线到地图上其他标记的距离。 方向代码。感谢。
var directions = L.mapbox.directions({
profile: 'mapbox.driving'
});
directions.setOrigin(L.latLng(lat1, long1));
directions.setDestination(L.latLng(lat2 , long2));
directions.query();
var directionsLayer = L.mapbox.directions.layer(directions).addTo(map);
var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions)
.addTo(map)
答案 0 :(得分:0)
检查路线的回复查询Route object。响应是 n 路由的数组。响应是distance: Number indicating the distance traveled in meters
您还可以使用Mapbox Command Line Interface查看路线查询中的回复。此特定查询的回复为"distance": 642
mapbox-cli> mapbox directions "[-79.4460, 43.6656]" "[-79.4434, 43.6602]"