Google Maps infoWindow only loading last record on markers

Add content as a property to marker object and use this.content in the event handler:

var marker = new google.maps.Marker(options);
marker.content="<div>Content goes here....</div>";

var infoWindow = new google.maps.InfoWindow();
google.maps.event.addListener(marker, 'click', function () {
                                infoWindow.setContent(this.content);
                                infoWindow.open(this.getMap(), this);
                            });

Leave a Comment