The Google Maps documentation describes an example of opening a single info window for one marker:
var infowindow = new google.maps.InfoWindow({ content: contentString }); var marker = new google.maps.Marker({ position: myLatlng, map: map, title:"Uluru (Ayers Rock)" }); google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); });
I need to put a lot of markers on the map so that each has its own info window with data from my previously prepared array. However, a simple change of the marker
, infowindow
to the marker[]
, infowindow[]
arrays in a loop did not give the desired result. Clicking on any marker crashes the info window of the last set marker. Tell me where to look for an error or an example for such a task.