Multiple routes on one map

2 posts / 0 new
Last post
nigel.boulton
Multiple routes on one map

Is it possible to have Multiple Routes with waypoints on one Map?

Effectively the code I am looking for would look something like this:

L.mapquest.key = 'EZGlvvVrnZvwFb1LA2JpgLX14aHof0Km';

var map = L.mapquest.map('map', {
    center: [53.2109, -2.6783],
    layers: L.mapquest.tileLayer('map'),
    zoom: 13,
    defaultMarker: "marker-sm"
});

L.mapquest.directions().route({
    start: 'Start Point',
    end: 'End Point',
    waypoints: ['Lots of waypoints']
});

L.mapquest.directions().route({
    start: 'Start Point',
    end: 'End Point',
    waypoints: ['Lots of other waypoints']
});

 

I need to have different colours for each route. I have investigated polylines but they are not suitable as a solution


MQBrianCoakley
Here is how I did it.

Here is how I did it.

 

 

directions = L.mapquest.directions();

directions.route({

start: "Denver, CO",

end: "Golden, CO"

}, putrouteonmap);

directions.route({

start: "Aurora, CO",

end: "Parker, CO"

}, putrouteonmap);

function putrouteonmap(err, data){

L.mapquest.directionsLayer({

directionsResponse: data,

}).addTo(map);

};