我正在尝试在我的页面上放置一个带有多个标记(> 1000)的谷歌地图,每个标记都有自己独特的信息窗口。我通过数组添加标记,标记似乎很好,但所有信息窗口都具有相同的确切内容。我很茫然,非常感谢你的信息。这是我的代码:
<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>