Bonjour,

Je suis entrain de créer un distancier à l'aide de l'api JS fourni par viamichelin.

Voici le code de ma page :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" xmlns:v="urn:schemas-microsoft-com:vml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>ViaMichelin JavaScript API V2 - Calculate a distance matrix</title>
		<style type="text/css">
			table{border-collapse:collapse}
			th{background-color:#9ff}
		</style>
	</head>
	<body onload="fLoadMatrix()">
		<h2>Distance Matrix with 'Recommanded by Michelin' itinerary type</h2>
		<div id="results"></div>
		<script src="http://apijsv2.viamichelin.com/apijsv2/api/js?key=JSV2GP20121203160810908186515886$165380&lang=fra" type="text/javascript"></script>
	<script type="text/javascript">
 
	var addresses = [ 
		{htm:"BG",lon:"05.270804",lat:"45.798583"},
		{htm:"BL",lon:"-0.690042",lat:"45.256747"},
		{htm:"BV",lon:"02.878217",lat:"47.510521"},
		{htm:"CA",lon:"06.229280",lat:"49.414254"},
		{htm:"CH",lon:"00.167677",lat:"47.228748"},
		{htm:"CS",lon:"04.754117",lat:"44.632049"},
		{htm:"CV",lon:"00.658053",lat:"46.452490"},
		{htm:"CZ",lon:"04.794829",lat:"50.090918"},
		{htm:"DA",lon:"02.520650",lat:"47.734250"},
		{htm:"FH",lon:"07.562887",lat:"47.904414"},
		{htm:"FL",lon:"-1.880390",lat:"49.537672"},
		{htm:"GF",lon:"00.845718",lat:"44.107986"},
		{htm:"GR",lon:"02.136628",lat:"51.014815"},
		{htm:"GN",lon:"05.790217",lat:"45.208066"},
		{htm:"NO",lon:"03.516924",lat:"48.516606"},
		{htm:"PA",lon:"00.634601",lat:"49.860538"},
		{htm:"PY",lon:"01.213532",lat:"49.978110"},
		{htm:"SA",lon:"04.754564",lat:"45.403929"},
		{htm:"SB",lon:"01.578910",lat:"47.719916"},
		{htm:"TN",lon:"04.732130",lat:"44.330958"},
	];
 
	function fLoadMatrix(){
		var out = "<table border='1'><tr><td>&nbsp;</td>";
		for(var i=0; i < addresses.length; ++i){
		 out += "<th>" + addresses[i].htm + "</th>";
		}
		out += '</tr>';
		for(i=0; i < addresses.length; ++i){
		 out += "<tr><th>" + addresses[i].htm + "</th>";
		 for(var j=0; j < addresses.length; ++j) {
		  out += "<td id='"+ i + '_' + j +"'> </td>";
		 }
		 out += "</tr>"; 
		}
		out += '</table>';
		$_id("results").innerHTML = out;
 
		//on run le tableau
 
			for(i=0; i < addresses.length; ++i){
				for(j=i+1; j < addresses.length; ++j) {
					var coordsdepart = "{lon:"+addresses[i].lon+", lat:"+addresses[i].lat+"}";
					var coordsarrivee = "{lon:"+addresses[j].lon+", lat:"+addresses[j].lat+"}";
 
					fLaunchRoutePlanner(coordsdepart, coordsarrivee, i, j);
					//document.write(coordsdepart + ' | ' + coordsarrivee + '<br>');
				}
			}
 
 
	};//fLoadMatrix
 
	function fLaunchRoutePlanner(coordsA, coordsB, i, j){
	VMLaunch("ViaMichelin.Api.Itinerary", {
	  steps:[//Array of Geo coodinates
	   {coords: coordsA}, //{coords: {lon: 2.24344, lat: 48.83381}} 
	   {coords: coordsB}
	  ],
	  //favMotorways: true,
	  data: ViaMichelin.Api.Constants.Itinerary.DATA.HEADER
	 },{
	  onSuccess : function (result) {
	   $_id(i + '_' + j).innerHTML = $_id(j + '_' + i).innerHTML  = Math.round(result.header.summaries[0].totalDist/1000) + 'km<br/>' + Math.round(result.header.summaries[0].totalTime/60) + 'mn';
	  },
	  onError : function (error) {
	   alert('Whoops! ' + error);
	  }});     
	};//fLaunchRoutePlanner
	</script>
</body>
</html>
Le problème c'est que lorsque j'ouvre ma page http://distancier.webuda.com/
j'ai droit au message "2 consecutive steps are identicals therefore route computation failed".
Je ne comprends pas. Je n'ai pas modifié grand chose de l'exemple http://dev.viamichelin.fr/web/api-ja...emples-v2#iti2.
Je sature et j'aurais besoin d'un coup d'oeil extérieur pour me rendre compte de la boulette.
Merci

Daniel