Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
How can i calculate routes but not draw them on the map? Leaflet

i have been trying to get this working for quite some time now, but cyclic references from the routes objects, asynchronous execution and whatnot made it hard for me to see the bigger picture.

I am also new to this, as one might have guessed.

So i try to get the closest three parkhouses from a START. So i calculate the routes to extract the e.routes.summary.totalDistance from them. However, i do not want them to be shown in the map just yet, because i want the three closest parkhouses and not every single one. On the other hand, Leaflet Routing Machine does not calculate these routes if i do not route.addTo(map).

It is a really hard time with this because it does defy all basics i have learned until now. Can someone give me a hint how to do it?

            route = L.Routing.control({
                name: id,
                serviceUrl: 'http://router.project-osrm.org/route/v1',
                waypoints: coords,
                plan: L.Routing.plan(coords, {
                    createMarker: function() {
                        return null;
                    }
                }),
                addWaypoints: false,
                draggableWaypoints: false,
                show: false,
                showAlternatives: true
            }).on('routesfound', function(e) {
                for (let index = 0; index < e.routes.length; index++) {
                    tmpRoutes.push(e);
                    tmpDistances.push(e.routes[index].summary.totalDistance);
                    tmpWayPoints.push(e.routes[index].waypoints)
                }
                map.removeControl(e.routes);
            }).addTo(map);
            //map.removeControl(route);
        }
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!