Google Map API中Infowindow的鼠标事件 [英] mouse event of infowindow in google map api
本文介绍了Google Map API中Infowindow的鼠标事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
google map api v3的信息窗口上是否有任何鼠标事件.就像closeclick事件一样.实际上,我要在3秒钟后关闭信息窗口.但是我想,如果鼠标指针在信息窗口上方,则它不应该关闭,请举个例子给我做.非常感谢.
Is there any mouse event on infowindow of google map api v3. Like closeclick event. Actually i m closing the info window after 3 seconds. but i want that if mouse pointer is over infowindow then it should not be close plesae give me example to do it.. Thank you very much.
我的代码写为---
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);
}
推荐答案
唯一的与鼠标活动有关的InfoWindow事件是 closeclick
.
您可以做的是在InfoWindow内容内使用< div>
并使用其鼠标事件.(活动区域周围将有一个无效的边界.)
What you can do is use a <div>
within the InfoWindow content and use its mouse events. (There will be an inactive border around the active area.)
这篇关于Google Map API中Infowindow的鼠标事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文