【问题标题】:Google Maps Infobox Autopan Issue谷歌地图信息框自动平移问题
【发布时间】:2012-08-13 05:16:57
【问题描述】:

我在使用信息框时遇到了一些问题 - http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html - 它没有考虑我布局中的标题和侧边栏。当有人单击标记并显示信息框时,它不会从标题和侧边栏(绝对位于 100% 宽度/高度的 Google 地图上方)下方自动平移,以便您可以看到它。

当我使用普通的 Infowindows(以及可以隐藏的侧边栏)时,我可以完美地工作,但我想使用 Infobox 来更好地控制样式/外观。为了做到这一点,我从这个问题中找到了第二个答案 - Ensure padding around markers on Google Maps for web - 并使用 div 并将其作为控件应用于地图。

这是问题的 JSFiddle - http://jsfiddle.net/nrjBB/

非常感谢任何帮助。

【问题讨论】:

    标签: javascript google-maps google-maps-api-3 infowindow


    【解决方案1】:

    从您的 html 中删除标题 div,它将正确平移。听起来你的 CSS 是错误的。

    试试这个:

    html:

    <div id="header"></div>
    <div id="map_canvas"></div>
    <div id="sidebar"></div>
    

    css:

    html { height: 100% }
    body { height: 100%; margin: 0; padding: 0 }
    #map_canvas { height: 100%; }
    #header { width: 100%; height: 50px; background: #000; }
    #sidebar { width: 100px; height: 100%; background: #999; position: absolute; top: 0; right: 0; }
    
    .info-box { background: #ffffff; }
    

    PS:感谢您将代码放在这里!我找了很久的信息框信息!!!

    【讨论】:

      【解决方案2】:

      您必须放置 map_canvas 的高度 (heightOfWindow -50),因为信息窗口将根据地图 div 平移,在您的情况下,地图 div 被标题隐藏

      【讨论】:

        猜你喜欢
        • 2015-06-14
        • 1970-01-01
        • 2017-09-13
        • 1970-01-01
        • 2013-02-16
        • 1970-01-01
        • 1970-01-01
        • 2015-09-20
        • 2012-02-23
        相关资源
        最近更新 更多