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

227
Views
How to make this javascript code better? works for A-B-C destinations, but is not dynamic, there's a bag when I want to go to destination "D"

Could be an algorithm issue.

used

var markers = new Map(); (for markers)
var routes = new Array(); (for lines from pt a to b and etc)

const step = (pointsObj) => {
    if (pointsObj.i < routes.length) {

        if (routes.length > 1)

        // move the user along the line by 1 step ()
        var pointA = routes[pointsObj.i];
        var pointB = routes[pointsObj.i + 1];

        // user moving gradually to the next point
        userMarker.setLatLng(
            new L.LatLng(
                userMarker.getLatLng().lat + (pointB.lat - pointA.lat) / maxNumSteps,
                userMarker.getLatLng().lng + (pointB.lng - pointA.lng) / maxNumSteps
            )
        );

        // number of steps user taking to move forward

        currentNumSteps++;
        // once the user reaches point B, set pointA = pointB and pointB = point C
        if (currentNumSteps == maxNumSteps) pointsObj.i++;
    }
};
about 4 years ago · Juan Pablo Isaza
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!