0
votes

By using Leaflet Routing Machine, OSRM and OpenStreetMap, I try to draw route between two places. Despite of numerous attemps, I've got always the same error:

Error: language code [object Object] not loaded
status: -3

The markers appear on map but the road is not visible.

Here my code:

<html>
    <head>
        <meta charset="utf-8" />
        <title>Leaflet Routing Machine Example</title>
        <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
        <link rel="stylesheet" href="leaflet-routing-machine-master/dist/leaflet-routing-machine.css" />
        <style>
            #mapid {
                height: 580px;
            }
        </style>
    </head>
    <body>
        <div id="mapid"></div>
        <script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
        <script src="leaflet-routing-machine-master/dist/leaflet-routing-machine.js"></script>
        <script>
        var mapid = L.map('mapid').setView([51.505, -0.09], 13);

        L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
            attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
        }).addTo(mapid);


        L.Routing.control({
            waypoints: [
                L.latLng(57.74, 11.94),
                L.latLng(57.6792, 11.949)
            ],
            routeWhileDragging: true,
            router: L.Routing.osrmv1({
                serviceUrl: 'http://router.project-osrm.org/route/v1'
            })
        }).addTo(mapid);
        </script>
    </body>
</html>

How to resolve this issue?

1

1 Answers

0
votes
<html>
<head>
    <meta charset="utf-8" />
    <title>Leaflet Routing Machine Example</title>
    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
    <link rel="stylesheet" href="http://www.liedman.net/leaflet-routing-machine/dist/leaflet-routing-machine.css" />
    <style>
        #mapid {
            height: 580px;
        }
    </style>
</head>
<body>
    <div id="mapid"></div>
    <script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
    <script src="http://www.liedman.net/leaflet-routing-machine/dist/leaflet-routing-machin.js"></script>
    <script>
    var mapid = L.map('mapid').setView([51.505, -0.09], 13);

    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(mapid);


    L.Routing.control({
        waypoints: [
            L.latLng(57.74, 11.94),
            L.latLng(57.6792, 11.949)
        ],
        routeWhileDragging: true,
        router: L.Routing.osrmv1({
            serviceUrl: 'http://router.project-osrm.org/route/v1'
        })
    }).addTo(mapid);
    </script>
</body>

It works properly. Will You explain what is the issue ?