我正在使用 GMAP3 jquery 插件。
我正在使用以下示例添加信息窗口http://gmap3.net/api/add-info-window.html
当鼠标点击离开信息窗口时,如何关闭信息窗口?
到目前为止我试过
var inside = false;
$('.infowindow').live('mouseenter',function(){
inside=true;
}).live('mouseleave', function(){
inside=false;
});
$("body").mouseup(function(){
if(!inside) $('.infowindow').remove();
});
但这会使 infowindow 保持打开状态,但会从 infowindow 类中删除内容。
我一直在尝试 infowindow.close() 但无法正常工作?
编辑:这是 addinfowindow 函数
function addInfoWindow(lati, longi, name, datestring) {
// get address
$("#dispatcher").gmap3({
action: 'getAddress',
latLng: [lati, longi],
callback: function (results) {
content = results && results[1] ? results && results[1].formatted_address : 'No Address';
// create infowindow
$('#dispatcher').gmap3({
action: 'addInfoWindow',
latLng: [lati, longi],
infowindow: {
options: {
content: name
},
events: {
closeclick: function (infowindow, event) {
//alert('closing : ' + $(this).attr('id') + ' : ' + infowindow.getContent());
}
},
apply: [{
action: 'setContent',
args: ['<span class="infowindow">' + name + '<br />' + content + '<br />' + datestring + '<span>']
}]
}
});
} // end callback
});
}