Google maps infowindow showing on wrong marker

后端 未结 5 539
失恋的感觉
失恋的感觉 2020-12-30 02:40

I have a piece of javascript code where I create markers and attach InfoWindows to them, like this:

for (var i = 0; i < 8; i++) {
    var marker = new goo         


        
5条回答
  •  一整个雨季
    2020-12-30 02:55

    for (var i = 0; i < 8; i++) {
        var marker = new google.maps.Marker({
           map: map,
           position: new google.maps.LatLng(lat[i], lng[i]),
           icon: '/static/images/iconsets/gmap/iconb' + (i+1) + '.png',
           content: 'test string'
        });
        google.maps.event.addListener(marker, 'click', function() {
            new google.maps.InfoWindow({
                content: this.content
            }).open(map, this);
        });
    }
    

提交回复
热议问题