我想用 onmouseover 事件而不是 onclick 事件显示信息窗口。
问题是当我将光标位置更改为标记之外时,我的信息窗口消失了,而我的信息窗口中有一个链接。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>multi-marqueurs</title>
<script src="http://maps.google.com/maps/api/js?sensor=true"
type="text/javascript"></script>
</head>
<body>
<div id="map" style="width: 800px; height: 700px;"></div>
<script type="text/javascript">
<!--
var locations = [
['<span id="ss">Jérôme et Catherine Blondel</span>', 49.898729,3.13606, 5],
['Laurent et Sabine Blondel', 50.684142,3.1360678, 4],
['Noël et Anne Marie Blondel', 49.953802, 2.360237, 3],
['Jean Luc et Catherine Blondel<br /> <a href="http://www.google.com/">GOOGLE</a>', 48.606369,2.886894, 2]
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 6,
center: new google.maps.LatLng(48.4,1.6),
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
},
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL,
position: google.maps.ControlPosition.TOP_RIGHT
},
scaleControl: true,
streetViewControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
/*var pictureLabel = document.createElement("img");
pictureLabel.src = "home.jpg";*/
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
/*title : "CRIAQ",
icon : "disk.png"*/
});
google.maps.event.addListener(marker, 'mouseover', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
google.maps.event.addListener(marker, 'mouseout', (function(marker, i) {
return function() {
infowindow.close(map, marker);
}
})(marker, i));
}
-->
</script>
</body>
</html>
我该怎么做?