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 36 37 38 39 40 41
|
var i=0;
var total ="";
var res = "";
res = data.split('/');
var length = res.length;
for(i=0;i<length-1;i++){
if (i%6==0){
alert(i); //ici
var vilA = ""+res[i]+"";
var vilB = ""+res[i+1]+"";
var latA = res[i+2];
var longA = res[i+3];
var latB = res[i+4];
var longB = res[i+5];
var map;
var directionsPanel;
var directions;
map = new GMap2(document.getElementById("map_canvas"));
map.addControl(new GLargeMapControl3D());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(47.082999, 2.395692), 6);
directionsPanel = document.getElementById("map_directions");
directions = new GDirections(map, directionsPanel);
directions.load("from: "+latA+", "+longA+" to: "+latB+", "+longB);
GEvent.addListener(directions,"load", function() {
var distance = directions.getDistance().meters;
distance=Math.floor(distance/1000);
var duree = directions.getDuration().seconds;
var heures=Math.floor(duree/3600);
var minutes=(duree/60)-(heures*60);
minutes=Math.floor(minutes);
total = total+""+vilA+" -> "+vilB+" distance : "+distance+"km"+" duree : "+heures+"h"+minutes+"min"+"<br />";
document.getElementById(""+divEcriture+"").innerHTML= total;
});
}
} |
Partager