Bonjour,

Je suis actuellement devant un problème de taille !
Je cherche à -pour faire court- afficher des marqueurs avec le "geocoding" (avec le nom du lieu) mais aussi à leur afficher des infowindow différentes ! Or apparemment il y a un problème de part le fait que geocoding est asynchrone (histoire de callback). Alors même que les marqueurs s'affichent très bien.
J'ai donc plusieurs marqueurs à des endroits différents mais avec une seule et même infowindow.
Bref, cela commence à vraiment être de trop haut niveau pour moi donc je demande de l'aide ici.

Voici le code (désolé c'est un peu le bordel) :

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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
 
 
 
 
 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>皆の天気byロマンスカイ</title>
<link rel="stylesheet" href="styletenki.css" />
 
  <!--[if lte IE 9]>
        <link rel="stylesheet" href="styleie.css" />
        <![endif]-->
 
 
 
 
 
 
 
 
</head>
 
 
 
<div id="container">
 
<h1>皆の天気byロマンスカイ</h1>
<center>
	<div class="blue">
	<div id="slatenav">
	<ul>
	<li><a href="index.html" title="Home" class="current">Home</a></li>
	<li><a href="user.php" title="Log-In">Log-In</a></li>
	<li><a href="regist.php" title="Register">Register</a></li>
	<li><a href="contact.html" title="Contact">Contact</a></li>
	</ul>
	</div>
	</div>
</a>
 
<h2>Welcome to everybody's weather page</h2>
 
<h4>場所を選んでください。 Choose a place.</h4>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
 
 /* var customIcons = {
      restaurant: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
        shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
      },
      ame: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png',
        shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
      }
    }; */
 
var geocoder;
 
 
    function load() {
    geocoder = new google.maps.Geocoder();
      var map = new google.maps.Map(document.getElementById("map"), {
        center: new google.maps.LatLng(47.6145, -122.3418),
        zoom: 4,
        mapTypeId: 'roadmap'
      });
      var infoWindow = new google.maps.InfoWindow;
 
      // Change this depending on the name of your PHP file
      downloadUrl("googleapitest.php", function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
          var name = markers[i].getAttribute("name");
          var date = markers[i].getAttribute("date");
         //var point = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
           //   parseFloat(markers[i].getAttribute("lgn")));
			  var type = markers[i].getAttribute("type");
			  var temperature = markers[i].getAttribute("temperature");
			  var cloud = markers[i].getAttribute("cloud");
			  var comment = markers[i].getAttribute("comment");
 
 
			  var html = "<b>" + name + "</b> <br/>"+ temperature +"</b> <br/>"+ cloud +"</b> <br/>"+ comment;
 
          //var icon = customIcons[type] || {};
 
 
   /* Appel au service de geocodage avec l'adresse en parametre */
   geocoder.geocode( { 'address': name}, function(results, status) {
    /* Si l'adresse a pu etre geolocalisee */
    if (status == google.maps.GeocoderStatus.OK) {
 
     /* Affichage du marker */
     var marker = new google.maps.Marker({
      map: map,
      position: results[0].geometry.location
     });
 
bindInfoWindow(marker, map, infoWindow, html);
 
     } 
    });
 
        }
      });
 
    }
 
 
 
 
 
 
    function bindInfoWindow(marker, map, infoWindow, html) {
      google.maps.event.addListener(marker, 'click', function() {
        infoWindow.setContent(html);
        infoWindow.open(map, marker);
      });
    }
 
    function downloadUrl(url, callback) {
      var request = window.ActiveXObject ?
          new ActiveXObject('Microsoft.XMLHTTP') :
          new XMLHttpRequest;
 
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          request.onreadystatechange = doNothing;
          callback(request, request.status);
        }
      };
 
      request.open('GET', url, true);
      request.send(null);
    }
 
 
 
    function doNothing() {}
 
    //]]>
 
  </script>
 
  </head>
 
  <body onLoad="load()">
    <div id="map" style="width: 800px; height: 600px"></div>
  </body>
 
</html>
Merci pour votre aide !