点击地图时关闭信息框 [英] Close Infobox when clicking on the map

查看:208
本文介绍了点击地图时关闭信息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Google Maps V3 API使用Infobox插件(http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html)



当用户在地图上点击信息框外部时,是否有太接近信息框?

div>

您需要使用addListener()

http://code.google.com/apis/maps/documentation/javascript/events.html#EventListeners



您可以调整此处找到的代码:

  google.maps.event.addListener(_point.popup, 'domready',function(){
//必须把它放在domready中,否则它不能找到div元素(直到InfoBox被打开时它是空的)

$( _point.popup.div _)。hover(
function(){
//当鼠标进入元素
时调用它},
function(){
//当鼠标离开元素
时,_point.popup.close()被调用。
}
);
});

Src:
使用InfoBox插件的Google Maps API v3 Event mouseover



您可以检测地图点击此:

  google.maps.event.addListener(map,'click',function(){ 

});

Infobox API:
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/ infobox / docs / reference.html


I'm using the Infobox plugin for Google Maps V3 API (http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html)

Is there anyway too close the infobox when the user clicks outside the infobox like on the map?

解决方案

You will want to use addListener()

http://code.google.com/apis/maps/documentation/javascript/events.html#EventListeners

You can adapt the code found here:

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: Google Maps API v3 Event mouseover with InfoBox plugin

You can detect a map click with this:

google.maps.event.addListener(map, 'click', function() {

});

Infobox API: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html

这篇关于点击地图时关闭信息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆