Bonjour ,
j'ai un probleme avec une infowindow,
j'ai une fonction javascript a laquelle je passe un tableau de données contenant un ensemble d'element, pour chaque je recois un nom et une adresse => il doit placer un marker pour chaque element et l'infowindow adequate au marker
tous marche bien, mes markers sont bien placé, mes infowindows sont placés aussi, mon seul probleme c'est que le meme texte s'affiche pour tous les markers qui est toujours celui le dernier dans le tableau
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 function findAllAddress(tabStation) { clearOverlays(); var n = tabStation.length; for (var i = 0; i < n; i++) { var address = tabStation[i][0]; var name = tabStation[i][1]; var info = '<DIV STYLE="line-height:1.35;overflow:hidden;white-space:nowrap;"><DIV STYLE=overflow:auto; width:50px; height:50px><font style="color:#000;"><b>Nom : </b>' + name + '<br /><b>Adresse : </b>' + address + '</font></div></div>'; // script uses our 'geocoder' in order to find location by address name geocoder.geocode({ 'address': address }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { // and, if everything is ok // we will center map var addrLocation = results[0].geometry.location; map.setCenter(addrLocation); // store current coordinates into hidden variables document.getElementById('lat').value = results[0].geometry.location.$a; document.getElementById('lng').value = results[0].geometry.location.ab; // and then - add new custom marker and Infowindow var addrMarker = new google.maps.Marker({ position: addrLocation, map: map, title: results[0].formatted_address }); // var infowindow = new google.maps.InfoWindow({ content: info }); infowindow.open(map, addrMarker); markers.push(addrMarker); } }); } }
je declare mon infowindow a chaque fois a l'interieur de la boucle
Partager