1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
function displayRoute(origin, destination) {
var malat = [49.846382088442,49.84557955042] ;var malong = [2.2642779350280,2.2633337974548] ;
var origin=waypts[0];
var destination=waypts[0];
alert(waypts[0]);
for(var j=0;j<coordolat.length;j++){myLatlng2.push({lat: coordolat[j], lng: coordolng[j]});}
var service = new google.maps.DirectionsService;
var display = new google.maps.DirectionsRenderer({
draggable: true,
map: map,
panel: document.getElementById('right-panel')
});
var waypts = []; // je crée un tableau de coordonnees de points de passage afin de transmettre le tableau dans service route
for(var j=0;j<myLatlng2.length;j++){
waypts.push({
location: myLatlng2[j],
});
}
service.route({
origin: waypts[0],
destination: destination,
waypoints: waypts,
travelMode: 'DRIVING',
avoidTolls: true
}, function(response, status) {
if (status === 'OK') {
display.setDirections(response);
} else {
alert('Could not display directions due to: ' + status);
}
}); |
Partager