Google Map API V3 - Marker Multiple
Bonjour,
J'essai de mettre sur une map google plusieurs marqueurs reliés par une polyline et ou chaque marker est cliquable est affiche du contenu HTML.
le soucis c'est peu importe le marker que je clic, ca affiche dans le dernier marker ajouté le texte sauvegardée du dernier marker
Voici mon code :
Code:
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
| var mapOptions = {
center: new google.maps.LatLng(tableauPointsPolyline[tableauPointsPolyline.length-1][1], tableauPointsPolyline[tableauPointsPolyline.length-1][2]),
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("ourTravelActu"),mapOptions);
var flightPlanCoordinates = new Array();
for(var i=0;i<tableauPointsPolyline.length;i++){
flightPlanCoordinates.push(new google.maps.LatLng(tableauPointsPolyline[i][1],tableauPointsPolyline[i][2]));
var latLng = new google.maps.LatLng(tableauPointsPolyline[i][1],tableauPointsPolyline[i][2]);
var marker = new google.maps.Marker({
map: map,
flat:false,
title:tableauPointsPolyline[i][0],
position: latLng
});
var contenuInfoBulle = '<h2>'+tableauPointsPolyline[i][0]+'</h2>' +
'<h3> Date : '+tableauPointsPolyline[i][4]+'</h3>' +
'<div class="contentInfo">'+tableauPointsPolyline[i][3]+'</div>';
var infoWindow = new google.maps.InfoWindow({
content : contenuInfoBulle,
position : latLng
});
google.maps.event.addListener(marker, 'click', function() {
infoWindow.open(map,marker);
});
markerArray.push(marker);
}
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map); |
a noter que flightPlanCoordinates est remplis depuis la bdd en ajax et contient un id, les coordonnées lat, et lng le titre et la description
Merci pour votre aide