perliedman / leaflet-routing-machine

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

Why it Detects the wrong route? #482

Closed mona-baharlou closed 6 years ago

mona-baharlou commented 6 years ago

Hi

I added waypoints to the routing machine but it detects a way that i didn't pass. I mean, for example i went from A point to B point from G(street name) street.but it shows C (wrong street)

the code is as below ..How can i solve it?

 var route = L.Routing.control(L.extend(window.lrmConfig, {
                        waypoints: latLngs,
                        show: true,
                        waypointMode: 'snap',
                        draggableWaypoints: false,
                        geocoder: L.Control.Geocoder.nominatim(),
                        routeWhileDragging: false,
                        reverseWaypoints: false,
                        showAlternatives: false,
                        addWaypoints: false,
                        lineOptions: {
                            styles: [{ color: colorPoly, opacity: 2, weight: 5 }]
                        },
                    })).addTo(map);

                    L.Routing.errorControl(route).addTo(map);
kaitoqueiroz commented 6 years ago

Same problem here.

L.tileLayer('https://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png', {
    attribution: '<a href="http://openstreetmap.org">OpenStreetMap</a>',
}).addTo(map);

var control = L.Routing.control({
  routeWhileDragging: false,
  draggableWaypoints: false,
  waypointMode: 'snap',
  show: true,
  addWaypoints: false,
  waypoints: waypoints,
  lineOptions: {
    styles: [{color: 'red', opacity: 0.6, weight: 6}]
  }
}).addTo(map);

I expected that the route continues to green route, but it make a turn.

sem titulo

I've tried waypointMode 'snap' and 'smart', but get same result.

perliedman commented 6 years ago

The exact route is determined by the routing backend (OSRM by default). So, there must be something in the OpenStreetMap data that makes OSRM choose the other route.

In other words, this is outside the scope of Leaflet Routing Machine, since it just displays the route provided by the backend.