i'm trying put a google maps on my page with multiple markers (>1000) and each one have their own unique info window. I'm adding the markers through an array and the markers seem to come up just fine, but all the info windows have the same exact content. I'm at a loss and would greatly appreciate your info. Here's my code:
<script>
var map;
var markersArray = [];
var infowindow = new google.maps.InfoWindow({
content: ''
});
function initialize() {
bounds = new google.maps.LatLngBounds();
usa = new google.maps.LatLng(37.09024, -95.712891);
var myOptions = {
zoom: 4,
center: usa,
mapTypeId: google.maps.MapTypeId.ROADMAP,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
plotMarkers();
}
// here is where the array content is contained
var webApps = [<%=strArray%>];
function plotMarkers(){
var i;
for(i = 0; i < webApps.length; i++){
codeAddresses(webApps[i]);
}
}
function codeAddresses(address){
// other variables
lat = address[3];
lng = address[4];
desc = address[0]
myLatlng = new google.maps.LatLng(lat,lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(desc);
infowindow.open(map, this);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="map_canvas" style="width: 100%; height: 600px;"></div>