perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.08k stars 350 forks source link

"Coordinates" undefined error while calling OSRM local server #503

Closed abnagpal closed 5 years ago

abnagpal commented 5 years ago

While calling leaflet-routing-machine with Osrm local server, I am getting error -

Error in routing{ error: 
   { status: -3,
     message: 'TypeError: Cannot read property \'coordinates\' of undefined' },
  type: 'routingerror',
  target: 
   { options: 
      { serviceUrl: 'http://127.0.0.1:5000/route/v1',
        waypoints: [Object],
        show: false,
        useHints: false } ...

Code:

 let routingControl = L.Routing.control({
        serviceUrl: 'http://127.0.0.1:5000/route/v1',
        waypoints: [
            startMarker.getLatLng(),
            destMarker.getLatLng()
        ],
        show: false,
        // router: new L.Routing.OSRMv1({
        //     serviceUrl: 'http://127.0.0.1:5000/route/v1',
        //     useHints: false
        // }),
        //allowUTurns: false,
        //serviceUrl: 'http://localhost:5000/route/v1',
        useHints: false
    });

When I open the following link in browser - (http://127.0.0.1:5000/route/v1/driving/13.405,52.52;13.405,52.525?overview=false&alternatives=true&steps=true), I get the following response(also, I have verified that I am getting the call on my Osrm server from the leaflet-routing-machine library):

{"waypoints":[{"location":[13.405003,52.520001],"distance":0.232045,"hint":"KjYCgP___38FAAAABwAAADEAAAAAAAAAzQrJQN5P3D952flBAAAAAAUAAAAHAAAAMQAAAAAAAADpAAAAS4vMAEFkIQNIi8wAQGQhAwQAHxTuYne-","name":"Spandauer Straße"},{"location":[13.404903,52.524927],"distance":10.456296,"hint":"rDIDgNxCA4AEAAAAHAAAACoAAABBAAAAFXbnPw0LO0Ei0YxBTdwpQgQAAAAcAAAAKgAAAEEAAADpAAAA54rMAH93IQNIi8wAyHchAwEATxPuYne-","name":""}],"routes":[{"distance":868.6,"duration":128.8,"weight_name":"routability","legs":[{"distance":868.6,"steps":[{"distance":205.8,"duration":23.7,"weight":23.7,"driving_side":"right","intersections":[{"location":[13.405003,52.520001],"bearings":[321],"entry":[true],"out":0},{"location":[13.404987,52.520013],"bearings":[45,150,225,330],"lanes":[{"valid":true,"indications":["left"]},{"indications":["left"],"valid":true},{"valid":true,"indications":["straight"]},{"valid":true,"indications":["straight","right"]}],"entry":[true,false,false,true],"in":1,"out":3},{"location":[13.40482,52.520157],"bearings":[45,150,225,315],"lanes":[{"valid":false,"indications":["left"]},{"indications":["left"],"valid":false},{"valid":true,"indications":["straight"]},{"valid":true,"indications":["straight"]}],"entry":[false,false,true,true],"in":1,"out":3}],"name":"Spandauer Straße","mode":"driving","maneuver":{"type":"depart","location":[13.405003,52.520001],"bearing_before":0,"bearing_after":321},"geometry":"_yp_IgdypAA@]`@W^CBILW^iA`Bk@z@CBg@t@KNEDOT"},{"distance":101.5,"duration":17.2,"weight":17.2,"driving_side":"right","intersections":[{"location":[13.403112,52.521449],"bearings":[60,135,240],"lanes":[{"indications":["left"],"valid":false},{"valid":true,"indications":["right"]}],"entry":[true,false,true],"in":1,"out":0},{"location":[13.404224,52.521827],"bearings":[60,135,240],"entry":[true,true,false],"in":2,"out":0}],"name":"Anna-Louisa-Karsch-Straße","mode":"driving","maneuver":{"type":"end of road","modifier":"right","bearing_before":320,"bearing_after":60,"location":[13.403112,52.521449]},"geometry":"abq_ImxxpAIc@GQKg@m@_CKg@"},{"distance":237.9,"duration":33,"weight":33,"driving_side":"right","intersections":[{"location":[13.404423,52.521892],"bearings":[45,240],"entry":[true,false],"in":1,"out":0},{"location":[13.404517,52.52196],"bearings":[0,75,225],"entry":[true,true,false],"in":2,"out":0},{"location":[13.403641,52.523107],"bearings":[60,150,300],"entry":[true,false,true],"in":1,"out":2}],"name":"An der Spandauer Brücke","mode":"driving","maneuver":{"type":"turn","modifier":"left","bearing_before":60,"bearing_after":50,"location":[13.404423,52.521892]},"geometry":"ydq_Is`ypAEMGEG?G@SNKHUPMJQLWP]VOHEBYNSREJgAhDAFMZ"},{"distance":136.3,"duration":17.6,"weight":17.6,"driving_side":"right","intersections":[{"location":[13.402606,52.523551],"bearings":[120,300,345],"entry":[false,true,true],"in":0,"out":2},{"location":[13.402834,52.524172],"bearings":[15,195,210],"entry":[true,false,false],"in":1,"out":0}],"name":"Rosenthaler Straße","mode":"driving","maneuver":{"type":"turn","modifier":"right","bearing_before":305,"bearing_after":347,"location":[13.402606,52.523551]},"geometry":"eoq_IiuxpAKDK@MEOGeAe@GEEAu@a@CACA_@S"},{"distance":147.7,"duration":27.9,"weight":27.9,"driving_side":"right","intersections":[{"location":[13.403158,52.524714],"bearings":[15,105,195],"entry":[true,true,false],"in":2,"out":1}],"name":"Neue Schönhauser Straße","mode":"driving","maneuver":{"type":"turn","modifier":"right","bearing_before":19,"bearing_after":98,"location":[13.403158,52.524714]},"geometry":"mvq_IwxxpA@Y@[Be@FaAHeB@a@?[C[CUGe@CO"},{"distance":39.4,"duration":9.4,"weight":9.4,"driving_side":"right","intersections":[{"location":[13.405293,52.524672],"bearings":[75,255,330],"entry":[true,false,true],"in":1,"out":2},{"location":[13.405235,52.524749],"bearings":[150,315],"entry":[false,true],"classes":["tunnel"],"in":0,"out":1},{"location":[13.405115,52.52481],"bearings":[135,315],"entry":[false,true],"in":0,"out":1}],"name":"","mode":"driving","maneuver":{"type":"turn","modifier":"left","bearing_before":67,"bearing_after":334,"location":[13.405293,52.524672]},"geometry":"evq_IafypAOHKVUf@AB"},{"distance":0,"duration":0,"weight":0,"driving_side":"right","intersections":[{"location":[13.404903,52.524927],"bearings":[128],"entry":[true],"in":0}],"name":"","mode":"driving","maneuver":{"type":"arrive","modifier":"right","bearing_before":308,"bearing_after":0,"location":[13.404903,52.524927]},"geometry":"ywq_IscypA"}],"duration":128.8,"weight":128.8,"summary":"An der Spandauer Brücke, Neue Schönhauser Straße"}],"weight":128.8}],"code":"Ok"}

Can you help me understand what I am missing here? Thank you.

abnagpal commented 5 years ago

There was a bug in my code. Apologies if any inconvenience caused.

Closing the issue.