点击地图在谷歌地图关闭信息窗口? [英] Closing info windows in google maps by clicking the map?

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

问题描述

我正在制作一个移动网络应用程序。



部分应用程序会丢弃多个标记,可以单击这些标记打开信息窗口。如果你继续使用地图而不确认它们,这会让我感到不快,如在iOS地图应用程序中。



有没有办法将它设置为如果用户点击底层地图,所有打开的信息窗口都关闭了?

解决方案

为地图的点击事件添加侦听器并关闭信息框它的处理程序

  google.maps.event.addListener(map,click,function(event){
for (var i = 0; i< ibArray.length; i ++){//我假设你有一些数组中的信息框
ibArray [i] .close();
}
} );

我在典型的网站上这样做,但没有看到任何理由在手机上无法使用

I'm making a mobile web app.

Part of the app drops several markers, which can be clicked to open info windows. It irritates me that these do not go away if you continue using the map without acknowledging them, as in the iOS maps app.

Is there a way to set it so that if the user clicks the underlying map, all open info windows are closed?

解决方案

add listener to map's click event and close infoboxes in its handler

google.maps.event.addListener(map, "click", function(event) {
    for (var i = 0; i < ibArray.length; i++ ) {  //I assume you have your infoboxes in some array
         ibArray[i].close();
    }
});

I do that on typical websites, but don't see any reason it wouldn't work on mobile

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

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