Bonjour,

Voici mon probleme : je n'arrive pas à recupérer le contenu de mon tableau en javascript.

Voici mon code :

Cote PHP :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
echo '<span><a href="#" onclick="show_parcour('.$Lat.','.$Lng.')">Visualiser le parcours</a></span>';
$Lat et $Lng contiennent des valeur numériques de longitude et latitude

Cote JS :
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
function show_parcour(tabLat,tabLng) {
  csswindow('<div id="map_canvas" style="width: 410px; height: 390px; margin:0px 0px -5px -5px; border: 1px solid black;z-index:100;"></div>',-1,true);
  // define the crosshair tile layer and its required functions
  var crossLayer = new GTileLayer(new GCopyrightCollection(""), 2, 15);
  crossLayer.getTileUrl =  function(tile, zoom) {
    return "./include/tile_crosshairs.png";
  }
  crossLayer.isPng = function() {return true;}
 
  // Create a new map type incorporating the tile layer
  var layerTerCross = [ G_PHYSICAL_MAP.getTileLayers()[0],
                        crossLayer ];
  var mtTerCross = new GMapType(layerTerCross,
                                G_PHYSICAL_MAP.getProjection(), "Ter+");
  var map = new GMap2(document.getElementById("map_canvas"),
      { size: new GSize(400,390) } );
  map.addMapType(G_PHYSICAL_MAP);
  map.addMapType(mtTerCross);
  alert(tabLat.lenght);
  var points = new Array();
  for(i=0;i<tabLat.lenght;i++)
  {
	var marker = new GMarker(new GLatLng(tabLat[i],tabLng[i]));
	points.push(marker);
  }
  var ligne = new GPolyline(points);
 
 
  map.setCenter(new GLatLng(tabLat[0], tabLng[0]), 13);
  map.addControl(new GLargeMapControl())
 
  map.addOverlay(ligne);
  //map.addOverlay(new GMarker(new GLatLng(49,1)));
 
 
 
 
 
  var mapControl = new GHierarchicalMapTypeControl();
 
  // Set up map type menu relationships
  mapControl.clearRelationships();
  mapControl.addRelationship(G_SATELLITE_MAP, G_HYBRID_MAP, "Labels", false);
  mapControl.addRelationship(G_PHYSICAL_MAP, mtTerCross, "Crosshairs");
 
  // Add control after you've specified the relationships
  map.addControl(mapControl);
}
J'essai d'afficher un parcours avec google map en ayant les coordonnées de longitude et latitude. Mais lors de mon alert(tabLat.lenght) il retourne undefined...

Je ne vois pas ce qui cloche.

Pouvez vous m'aider ?
Merci.