perliedman / lrm-graphhopper

Support for GraphHopper in Leaflet Routing Machine
ISC License
31 stars 52 forks source link

How to add multiple intermediate point routing? #33

Closed RilusMahmud closed 2 years ago

RilusMahmud commented 3 years ago

I wanted to visit multiple intermediate points with graphhopper and leaflet. How can I do that?

fuadhasni commented 2 years ago

I just read the issue, leaving an answer anyone would need help with. We add multiple way points the following way,

            var P = Points.split("|");
            var latlng = "";
            for (var i = 0; i < P.length; i++) {
                latlng = P[i].split(",");
                WayPoints.push(new L.Routing.Waypoint(L.latLng(latlng[0], latlng[1]), latlng[2]));
            }
            var routing_control = L.Routing.control({
                waypoints: WayPoints,
                routeWhileDragging: true,
                showAlternatives: true,
                fitSelectedRoutes: true,
                show: false,                
RilusMahmud commented 2 years ago

Thanks for the reply