perliedman / leaflet-routing-machine

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

Sometimes no route is calculated #488

Closed CoughSyrup123 closed 6 years ago

CoughSyrup123 commented 6 years ago

Hi there,

I have a problem with calculating a route. Sometimes no route is calculated. I have no way of reproducing that and it doesn't happen every time.

My code how i calculate the route with two waypoints:

function StartRouting(SWLat,SWLng,NELat,NELng){
  L.Routing.control({
    waypoints: [
      [SWLat,SWLng],
      [NELat,NELng]
    ],
    createMarker: function() { return null; },
    addWaypoints: false,
    show: false,
    draggableWaypoints: false,
    lineOptions: {
      styles: [
        {color: 'black', opacity: 0, weight: 0},
        {color: 'white', opacity: 0, weight: 0},
        {color: 'gray',  opacity: 1, weight: 2}
      ]
    },
    geocoder: L.Control.Geocoder.nominatim(),
  }).addTo(map);
}
CoughSyrup123 commented 6 years ago

I have integrated the error display and now get this message sometimes: 2018-09-14 12_39_05-_ctel200f

Would it be possible that the problem is not my code but the page which calculates the route? I use nominatim (URL: http://nominatim.openstreetmap.org/search/) for route calculating

perliedman commented 6 years ago

Hi!

It is most likely that the issue is OSRM's demo server, which suffers from a lot of load issues and quite frequently (IMHO) responds with HTTP 429 error codes, which prevents Leaflet Routing Machine from displaying a route.

So, if you need better availability, you need to either use a paid service provider (Mapbox is good and works well with Leaflet Routing Machine, but there are multiple other as well), or set up your own routing server.

I am closing this issue, since it is outside the scope of Leaflet Routing Machine to address this.