Bonsoir,

Je sèche sur un programme JS (Google Maps) qui globalement fonctionnait bien au fil de mes étapes, jusqu'à ce que j'obtienne un "missing ; before statement" pour la ligne var beaches[] = new Array(address,latitude,longitude,5); de mon script ci-dessous et évidemment, je ne vois pas ce qui cloche. Ca semble être lié à la manière de construire mon tableau multidimensionnel, mais je ne vois pas pourquoi... Une idée ?

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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
    <script type="text/javascript">
 
var directionDisplay;
  var directionsService = new google.maps.DirectionsService();
  var map;
 
var listbeaches = ['Bondi Beach', 'Coogee Beach', 'Cronulla Beach', 'Manly Beach', 'Maroubra Beach'];
 
function geocord(address) {
geocoderq = new google.maps.Geocoder();
geocoderq.geocode({ 'address': address }, function(results, status) {
  if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
// erreur pour ligne ci-dessous : missing ; before statement
var beaches[] = new Array(address,latitude,longitude,5);
//var beaches[] = ['Bondi Beach',-33.890542,151.274856,5];
}
});  
}
 
  function initialize() {
      geocoder = new google.maps.Geocoder();
    directionsDisplay = new google.maps.DirectionsRenderer();
    var europe = new google.maps.LatLng(-33.890542,151.274856);
    var myOptions = {
      zoom:5,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: europe
    }
    map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
 
for (i = 0; i < listbeaches.length; i++)
{
var address = listbeaches[i];
geocord(address,i);	
}
 
setMarkers(map, beaches);
 
    directionsDisplay.setMap(map);
  }
 
 
function setMarkers(map, locations) {
  // Add markers to the map
 
  // Marker sizes are expressed as a Size of X,Y
  // where the origin of the image (0,0) is located
  // in the top left of the image.
 
  // Origins, anchor positions and coordinates of the marker
  // increase in the X direction to the right and in
  // the Y direction down.
  var image = {
    url: 'http://www.aim-awards.co.uk/media/png/beachflag.png',
    // This marker is 20 pixels wide by 32 pixels tall.
    size: new google.maps.Size(20, 32),
    // The origin for this image is 0,0.
    origin: new google.maps.Point(0,0),
    // The anchor for this image is the base of the flagpole at 0,32.
    anchor: new google.maps.Point(0, 32)
  };
  // Shapes define the clickable region of the icon.
  // The type defines an HTML &lt;area&gt; element 'poly' which
  // traces out a polygon as a series of X,Y points. The final
  // coordinate closes the poly by connecting to the first
  // coordinate.
  var shape = {
      coord: [1, 1, 1, 20, 18, 20, 18 , 1],
      type: 'poly'
  };
  for (var i = 0; i < locations.length; i++) {
    var beach = locations[i];
    var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
    var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image,
        shape: shape,
        title: beach[0],
        zIndex: beach[3]
    });
  }
}
 
 
function clickroute(address,zoom) {
//	map.panTo(new google.maps.LatLng(lati, long));
//	map.setZoom(zoom);lati,long,zoom
//return false; //this will cancel your navigation
 
geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function(results, status) {
  if (status == google.maps.GeocoderStatus.OK) {
    map.setCenter(results[0].geometry.location);
	map.setZoom(zoom);
}
});
 
}
 
google.maps.event.addDomListener(window, 'load', initialize);
 
 
 </script>