Je n'arrive pas à voir mes marqueurs pour afficher différents infowindows. Les marqueurs affichent toujours le contenu du dernier "contentString".Google Maps - Marqueurs multiples - 1 Problème InfoWindow
J'ai lu quelques autres messages mais aucun d'entre eux semble aider.
Voici le code:
function setMarkers(branches, map) {
var bounds = new google.maps.LatLngBounds();
var contentString = null;
var infowindow = null;
infowindow = new google.maps.InfoWindow();
for (var i = 0; i < branches.length; i++) {
var marker = null;
branch = branches[i];
var myLatlngMarker = new google.maps.LatLng(branch[0], branch[1]);
contentString = '<p>' + branch[3] + '</p>';
var marker = new google.maps.Marker({
position: myLatlngMarker,
map: map,
title: branch[2]
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map, this);
});
bounds.extend(myLatlngMarker);
}
map.fitBounds(bounds);
}
Quelqu'un peut-il voir ce que je fais mal?
Merci
Le problème avec cette approche est que Google ajoute un jour La propriété info à Marker peut casser quelque chose. Cela semble également faux parce que info est vraiment une propriété de infoWindow, pas le marqueur. – puckhead
Excellente solution! –