问题
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.
My Code is written as follow---
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);
}
回答1:
The only InfoWindow event relevant to mouse activity is closeclick.
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.)
来源:https://stackoverflow.com/questions/11574372/mouse-event-of-infowindow-in-google-map-api