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

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

问题描述

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



InfoWindows保持打开状态,除非您明确地单击关闭图标。这意味着,如果您将鼠标悬停在地图标记上,您可以一次打开2个InfoWindow。



问题:我如何使它成为如此只有当前活动的InfoWindow已打开且所有其他InfoWindows已关闭?意思是说,每次只能打开1个以上的InfoWindow? close()函数。只需跟踪上次打开的窗口,并在创建新窗口时调用关闭函数。



此演示版具有您正在查找的功能。我在 Maps API V3演示库中找到了它。


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

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.

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?

解决方案

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.

This demo has the functionality you're looking for. I found it in the Maps API V3 demo gallery.

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

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