0
我正在使用google maps javascript api,标记监听器。 当我点击标记infowindow应该弹出。 在for循环中,我添加了多个(本例中为3个)标记。 下面是代码:多标记监听器
for (z = 0; z < 3; z++) {
arrMarkers.push(new google.maps.Marker({
position: flightPlanCoordinates[arrCoords.length-1],
map: map, title: 'Kraj', clickable: true
}));
arrInfoWindow.push(new google.maps.InfoWindow({
content: 'Hello world'
}));
google.maps.event.addListener(arrMarkers[z], 'click', function() {
arrInfoWindow[z].open(map, arrMarkers[z]);
});
}
信息窗口不弹出。
我找到了解决方案,替换:arrInfoWindow [Z]。开(地图,arrMarkers [Z]);用arrInfoWindow [z] .open(map,this) – user1455966