Я пытаюсь использовать Leaflet Routing Machine для отображения маршрута между двумя точками. Я реализовал эти функции точно так же, как в примере на веб-сайте поставщика подключаемых модулей. Я получаю два маркера, но путь не отображается.
<html lang = "en-US" xmlns = "http://www.w3.org/1999/xhtml">
<head profile = "http://gmpg.org/xfn/11">
<title>Wanderrouten24</title>
<meta http-equiv = "Content-Type" content = "text/html; charset=UTF-8" />
<link rel = "stylesheet" type = "text/css" href = "http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<link rel = "stylesheet" href = "leaflet-routing-machine-3.2.7/dist/leaflet-routing-machine.css" />
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js'></script>
<script type='text/javascript' src='http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js'></script>
<script src = "leaflet-routing-machine-3.2.7/dist/leaflet-routing-machine.js"></script>
</head>
<body>
<div id = "map" style = "width: 800px; height: 440px; border: 1px solid #AAA;"></div>
<script type='text/javascript' src='maps/createRoute.js'></script>
</body>
</html>
JS:
var map = L.map( 'map', {
center: [20.0, 5.0],
minZoom: 2,
zoom: 2
});
L.Routing.control({
waypoints: [
L.latLng(49.47748, 8.42216),
L.latLng(49.47648, 8.32216)
],
routeWhileDragging: true
}).addTo(map);
L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href = "https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
subdomains: ['a', 'b', 'c']
}).addTo( map );
map.setView([49.47748, 8.42216], 15);
map.locate({setView: true, watch: true}) /* This will return map so you can do chaining */
.on('locationfound', function(e){})
.on('locationerror', function(e){
console.info(e);
alert("Location access denied.");
});



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Скорее всего, вы получите такую ошибку:
TypeError: Cannot read property 'maneuver' of undefined
поскольку Библиотека leaflet-routing-machine несовместим с leaflet v0.7.7, здесь представляет собой аналогичную проблему, о которой сообщалось.
Итак, решением было бы обновить leaflet до версии 1.0.0 или выше, после обновления маршрут должен быть напечатан, как ожидалось, вот демо