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

127
Views
How do i redirect to maps page with optimizeWaypoints configuration of maps API?

I'm using maps api in my app and when i what to see the created route i have the choice of set optimizeWaypoints = true to organize the waypoints but... I need to see that route on google maps page, but whenever i try that the way points are not "optimized".

I have done this that way:

for (var i = 0; i < wayptss.length; i++) {string_de_waypoints += wayptss[i] + '/';} var addresses = string_de_waypoints;

 var address2 = document.getElementById("end").value;

 // window.open("https://maps.google.ch/maps?saddr=["+address1+"]&daddr=["+address2+"] to:["+address3+"] to: ["+address4+"]to: ["+address5+"]")

        link_maps = "https://www.google.ch/maps/dir/"+address1+"/"+addresses+address2;
        window.open(link_maps)

The value come from here:

 const waypts = [];
        const checkboxArray = document.getElementById("waypoints");
        wayptss=[];
        for (let i = 0; i < checkboxArray.length; i++) {
            if (checkboxArray.options[i].selected) {
            waypts.push({
                location: checkboxArray[i].value,
                stopover: true,
            });
            //-----------------HERE--------------------------------
            wayptss.push(checkboxArray[i].value,
            );
            }

the input adresses staff

Well... What i want to know is, if I have some way to do that like exporting directly the route to google maps or something like that. Or if not at least a way to optimize the route waypoints array by getting his distance or something like that.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Ok i found a solution. I used this:

summaryPanel.innerHTML += route.legs[i].start_address + " to ";
summaryPanel.innerHTML += route.legs[i].end_address + "<br>";
summaryPanel.innerHTML += route.legs[i].distance.text + "<br><br>";

https://developers.google.com/maps/documentation/javascript/directions

about 4 years ago · Juan Pablo Isaza Report
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!