如何通过Leaflet地图上的Waypoint显示方向。
我使用“传单路由机”,但我无法查看路线
L.Routing.control({
waypoints: [
L.latLng(52.5002237, -2.94),
L.latLng(52.5002237, -0.949),
L.latLng(52.5002237, -1.949)
],
autoRoute: true,
routeWhileDragging: true,
}).addTo(map);
任何想法或示例plz
你可以在这里找到一个完整的例子(https://codepen.io/mahmoud-nb/pen/RZzNYr)
答案 0 :(得分:1)
您应该检查控制台错误。对router.project-osrm.org的请求失败:
无法加载资源:服务器响应状态为503(服务不可用:后端服务器处于容量状态)
答案 1 :(得分:0)
leaflet-routing-machine.css
中添加其他样式到angular.json文件中:"styles": [
"node_modules/leaflet-routing-machine/dist/leaflet-routing-machine.css"
]
import 'leaflet-routing-machine';
并将路由控件添加为波纹管:L.Routing.control({
waypoints: [
L.latLng(57.74, 11.94),
L.latLng(57.6792, 11.949)
],
collapsible: true, // hide/show panel routing
routeWhileDragging: true
// ...
}).addTo(this.map);