单击地图时关闭信息框
Close Infobox when clicking on the map
我正在使用Google Maps V3 API的Infobox插件(http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html)
当用户像在地图上一样在信息框外点击时,信息框是否太近了?
如果您将信息窗口作为全局变量,或者至少在方便的地方保存一个表示要添加的单个信息框的变量,那么实际上会容易得多。
编辑:只是为了澄清:例如,它应该而不是为window.myInfoBox
。对于global,我指的是您参考信息框的单个点
google.maps.event.addListener(map, 'click', function() {
if(infowindow){
infowindow.close();
}
});
仅此而已:-(
您需要使用addListener((
http://code.google.com/apis/maps/documentation/javascript/events.html#EventListeners
您可以调整此处的代码:
google.maps.event.addListener(_point.popup, 'domready', function() {
//Have to put this within the domready or else it can't find the div element (it's null until the InfoBox is opened)
$(_point.popup.div_).hover(
function() {
//This is called when the mouse enters the element
},
function() {
//This is called when the mouse leaves the element
_point.popup.close();
}
);
});
Src:谷歌地图API v3事件鼠标悬停与InfoBox插件
你可以用这个检测地图点击:
google.maps.event.addListener(map, 'click', function() {
});
API信息框:http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html
这可能对您有用。。
var inside = false;
$('#foo').live('mouseenter',function(){
inside=true;
}).live('mouseleave', function(){
inside=false;
});
$("body").mouseup(function(){
if(!inside) $('#foo').remove();
});
相关文章:
- 谷歌地图点击潜水触发信息窗口
- 将FlowPlayer嵌入谷歌地图信息窗口
- 当我浏览回页面时,谷歌地图信息窗口不会弹出
- 谷歌地图信息窗口Z索引
- 谷歌地图-数据库中的标记只显示最后一行的信息
- 谷歌地图信息窗口为每个标记显示相同的内容
- Cartodb信息窗口未在地图上显示变量
- 地图标记信息不显示
- 为位于路线上的谷歌地图标记(起点和终点)设置一个信息窗口
- 信息窗口谷歌地图点击事件给出错误
- Javascript谷歌地图每个信息窗口
- 更新打开的谷歌地图信息窗口
- 谷歌地图/SQL-添加链接到信息面板中的字段
- 禁用角度地图中标记和信息窗口的ng点击
- 在谷歌地图的信息窗口内点击按钮
- 谷歌地图API-信息窗口显示谷歌位置API信息
- 谷歌地图API-获取信息窗口打开时,点击一个圆圈
- Google 地图信息窗口仅显示首次点击时的信息
- 谷歌地图 API - 指向地点详细信息页面的链接
- 信息寡妇与不同的信息在折线谷歌地图 API v3