谷歌地图:自动关闭打开 InfoWindows? [英] Google Maps: Auto close open InfoWindows?

查看:32
本文介绍了谷歌地图:自动关闭打开 InfoWindows?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上,我使用的是 Google Maps API v3在地图上放置房屋标记.

On my site, I'm using Google Maps API v3 to place house markers on the map.

除非您明确单击关闭图标,否则信息窗口将保持打开状态.这意味着,如果您将鼠标悬停在地图标记上,您可以一次打开 2 个以上的信息窗口.

The InfoWindows stay open unless you explicitly click the close icon. Meaning, you can have 2+ InfoWindows open at a time if you hover over the map marker.

问题:如何才能只打开当前活动的信息窗口而关闭所有其他信息窗口?意思是,一次不会打开超过 1 个 InfoWindow?

Question: How do I make it so that only the current active InfoWindow is open and all other InfoWindows are closed? Meaning, no more than 1 InfoWindow will be open at a time?

推荐答案

有一个 close() 函数.只需跟踪上次打开的窗口,并在创建新窗口时调用其关闭函数.

There is a close() function for InfoWindows. Just keep track of the last opened window, and call the close function on it when a new window is created.

这篇关于谷歌地图:自动关闭打开 InfoWindows?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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