Rendering Map and Waypoints in JavaScript

I have an issue where when I render my map via JavaScript, I can’t add waypoints. My map only shows start and end points.

    const ORS_API_KEY = "MY_KEY"; // Substitua pela sua chave de API

    const startPoint = '-46.633308,-23.550520'; //São Paulo (SP)
    const endPoint = '-43.172896,-22.906847'; //Rio de Janeiro (RJ)
    const waypoints =['-51.229994,-30.034647']; //Grande do Sul (RS)

    const apiUrl = `${ORS_API_KEY}&start=${startPoint}&end=${endPoint}&waypoints=${waypoints.join('|')}`;

    function exibirRotaNoMapa(data) {
        const routeData = data.features[0].geometry.coordinates;
        const map ='map').setView([0, 0], 13);
        L.tileLayer('https://{s}{z}/{x}/{y}.png', {
            maxZoom: 19,
        const routeLatLng = => L.latLng(coord[1], coord[0]));
        const routePolyline = L.polyline(routeLatLng, { color: 'blue' }).addTo(map);

Please read the documentation:{profile}/get
You are using GET instead of POST which only supports start & end parameter.

1 Like