I downloaded the Leaflet Routing Machine from https://github.com/perliedman/leaflet-routing-machine. Unzipped and opened the index.html in my browser to see how it looks, and got an error as shown in the image below:

ERR_FILE_NOT_FOUND file://router.project-osrm.org/viaroute?instructions=true&loc=57.74,11.94&loc=57.6792,11.949&jsonp=_l_routing_machine_0

enter image description here


<!DOCTYPE html>
    <meta charset="utf-8" />
    <title>Leaflet OSRM Example</title>
    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
    <link rel="stylesheet" href="../css/leaflet-routing-machine.css" />
    <link rel="stylesheet" href="index.css" />
    <div id="map" class="map"></div>
    <script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
    <script src="../src/L.Routing.Autocomplete.js"></script>
    <script src="../src/L.Routing.OSRM.js"></script>
    <script src="../src/L.Routing.Line.js"></script>
    <script src="../src/L.Routing.Itinerary.js"></script>
    <script src="../src/L.Routing.Plan.js"></script>
    <script src="../src/L.Routing.Control.js"></script>
    <script src="Control.Geocoder.js"></script>
    <script src="index.js"></script>
  • Can you post the portion of the index.html file that is referring to that file location? – Erica Aug 12 '14 at 14:01
  • It is exactly the site I quoted index.html. edited the qestão with the code for you to see. – csf Aug 12 '14 at 14:06

I think that this will not work from your desktop, but needs to be uploaded to a server. These lines in L.Routing.OSRM.js

23  L.Routing.OSRM = L.Class.extend({ 
24      options: { 
25          serviceUrl: '//router.project-osrm.org/viaroute', 
26          geometryPrecision: 6 
27      }, 

are getting file:// appended to the front (file://router.project-osrm.org/viaroute?...) instead of http:// and causing the file-not-found error.

I do not have enough JavaScript experience to help with debugging aside from suggesting you access it from the web instead of your local computer.

  • It's enough to pass serviceUrl: 'http://router.project-osrm.org/viaroute' to the options. For instance if you are creating L.Routing.control, you can write something like this. – TLama Feb 3 '15 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.