1

google map api v3的信息窗口上是否有任何鼠标事件。像 closeclick 事件。实际上我在 3 秒后关闭了信息窗口。但我希望如果鼠标指针在信息窗口上,那么它不应该关闭请给我一个例子来做这件事。非常感谢。

我的代码编写如下---

function generateMarkers(locations, is_paid) 
    { var marker; for (var i = 0; i < locations.length; i++)
     {
                var marker;
                for (var i = 0; i < locations.length; i++) {

                    createMarker(new google.maps.LatLng(locations[i][0], locations[i][1]), locations[i][2], locations[i][3], locations[i][4], is_paid);
                }
            }

            function createMarker(pos, name, town, image, is_paid) {
                var infowindow;

                var marker = new google.maps.Marker({
                    position: pos,
                    map: map,  // google.maps.Map 
                    title: name,
                    icon: "images/red.png"

                });
                infowindow = new google.maps.InfoWindow
                ({
                    content: '<div id="dvContent" onmouseover="clearTime()" onmouseout="clearwindow()"><div style="color:black;float:left"><img src="' + image + '" width="50px" height="50px"/></div><div style="color:black;margin-left:60px">' + name + '<br>Address:' + town + '<br><a href="#" target="_blank" style="color:blue">www.somethingcupid.com</a></div></div>'


                });

                google.maps.event.addListener(marker, 'mouseover', function () {
                    if (is_paid != "True") {

                        document.getElementById("divPopup").style.display = "block";
                    }
                    else {

                        infowindow.open(map, marker);


                    }

                });



                google.maps.event.addListener(marker, 'mouseout', function () {
                    if (is_paid != "True") {

                        document.getElementById("divPopup").style.display = "block";
                    }
                    else {

                        t = setTimeout(function () { infowindow.close() }, 3000);

                    }

                });
}

                function clearTime() {
                    clearTimeout(t);
                }enter code here

                function clearwindow() {
                    setTimeout(function () { infowindow.close() }, 3000);
                }
4

1 回答 1

0

唯一与鼠标活动相关的InfoWindow 事件closeclick是.

您可以做的是<div>在 InfoWindow 内容中使用 a 并使用其鼠标事件。(活动区域周围会有一个非活动边框。)

于 2012-07-20T07:12:54.377 回答