Cannot read property 'alternateRoutes' of undefined

4 posts / 0 new
Last post
joeycaron
Cannot read property 'alternateRoutes' of undefined

Hi !

I get this error : Uncaught TypeError: Cannot read property 'alternateRoutes' of undefined  in:mq-routing.js?key=this_is_my_key :61

the error is at : var J=Q.route.alternateRoutes;

There the code i have

function createTrajet(dusList) {
            GroupLatLng = [];
            for (var i = 0; i < dusList.length; i++) {

                var latLng = { lat: dusList[i].Lattitude, lng: dusList[i].Longitude};
                GroupLatLng.push(latLng);
            }

mapTrajet = L.map('trajetMap', {
                layers: MQ.mapLayer(),
                center: [46.814184, -71.207425],//Centre la carte sur Québec
                zoom: 14
            });

            dir = MQ.routing.directions();
          
           dir.optimizedRoute({
                locations: GroupLatLng
            });

            mapTrajet.addLayer(MQ.routing.routeLayer({
                directions: dir,
                fitBounds: true
            }));
        }

Thank you for your help.


MQBrianCoakley
Hi Joey,
Hi Joey,   Is there a url where we can see this happening?

joeycaron
Nervermind,it was on my side

Nervermind,it was on my side,in the part where i build latLng i should have done : var location = {latLng:{ lat: dusList[i].Lattitude, lng: dusList[i].Longitude };

Thank you for your time !


MQBrianCoakley
Thanks for letting us know!
Thanks for letting us know!