具有动态自动定位功能的 Google 地图 V3 工具提示弹出窗口
我正在寻找一个可与 Google Maps V3 配合使用的弹出窗口,该弹出窗口支持相对于标记自动定位弹出窗口,以便整个弹出窗口始终在地图视口中可见。我正在尝试破解 InfoBox 库来完成这项工作,但事实证明这是一个很大的麻烦。我还研究了 QTip2,它显示了一些希望,但也有一些缺点,例如具有定位,但必须手动设置。
编辑:解决方案需要不平移地图以显示弹出窗口。
I'm looking for a popup that will work with Google Maps V3 that supports auto-positioning the popup in relation to the marker such that the whole popup window is always visible within the map viewport. I'm trying to hack the InfoBox library to make this work but it's proving to be a big hassle. I've also looked at QTip2 which shows some promise but also has some shortcomings such as having positioning, but it must be set manually.
EDIT: The solution needs to to not pan the map to show the popup window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 SmartInfoWindow 的快速搜索中找到了 V3 演示库。看起来它就像你想要的那样。这是 Google 代码项目。
I found SmartInfoWindow in a quick search at the V3 Demo Gallery. It seems like it does just what you want. Here's the google code project.
在 SmartInfoWindow 的帮助下,我能够添加到 InfoBox 中,让它执行我想要的操作。这是一个部分定制的解决方案,因此您可能需要调整定位。您只需获取 InfoBox 每个角的 div 位置,将这些角转换回纬度/经度,然后获取地图边界并查看角是否在边界内。如果不是,那么您可以根据哪些角落不在地图上相应地调整信息框位置。
I was able to add on to InfoBox to get it to do what I wanted with a little help from SmartInfoWindow. This is a partially customized solution so you may need to tweak the positioning. You just grab the div position of each corner of the InfoBox, convert those corners back to lat/lng and then grab the maps bounds and see if the corners are within the bounds. If they aren't then you adjust the InfoBox position accordingly depending on which corners are off the map.