通过单击地图关闭谷歌地图中的信息窗口? [英] Closing info windows in google maps by clicking the map?

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

问题描述

我正在制作一个移动网络应用.

I'm making a mobile web app.

部分应用程序会放置多个标记,点击这些标记即可打开信息窗口.如果你继续使用地图而不承认它们,这些不会消失,这让我很恼火,就像在 iOS 地图应用中一样.

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天全站免登陆