Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

226
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda