首页 文章

Thickbox和谷歌 Map 链接

提问于
浏览
1

我正在使用jQuery的thickbox,并希望将其用于Google Map 链接 .

我见过的方法不适用于我正在使用的链接(URL)格式 .

网址格式:

http://maps.google.com/?q=1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003

所以,如果我使用这个:

<a class='thickbox' href='http://maps.google.com/?q=1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003'>
   Map
</a>

它只是重定向到Google Map 页面而不是打开谷歌 Map 的弹出窗口 . 我正在尝试将ajax调用附加到URL

?height=300&width=300

但它不起作用

4 回答

  • 0

    要在Thickbox中打开iframe中的网址,您需要将其附加到您的网址:

    &KeepThis=true&TB_iframe=true&height=400&width=600
    

    有关iFramed内容,请参阅ThickBox说明 .

    你确实应该删除双 http://maps.google.com/?q= 但是如果你没有做好的话,它应该仍然有效 . )

  • 2

    也许是因为你有这个部分:

    http://maps.google.com/?q=
    

    你的链接两次?

  • 0

    我发布了一个单独的答案,因为有一种不同的方法可以实现这一点 - 没有厚盒中的整个谷歌 Map 页面 - 我们只想要 Map 本身 .

    此方法将 Map 放置在页面上的隐藏iframe中 . 这是Thickbox的“内联内容”方法 .

    <a href="#TB_inlinemodalContent?height=410&width=505&inlineId=hiddenDiv" title="add a caption to title attribute / or leave blank" class="thickbox">Show hidden modal content.</a>
    
    <div id="hiddenDiv" style="display:none;">
        <iframe width="500" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?q=1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003&amp;t=h&amp;output=embed"></iframe>
    </div>
    

    通过添加 output=embed ,我们只能在iframe中获取 Map 本身 . t=h 使其成为卫星 Map . 您可以将这些添加到原始方法中的链接上(直接打开iframe),但混合Google Maps和Thickbox的网址参数似乎可以稍微抛弃它 .

  • 2

    您可能需要删除您的双倍

    http://maps.google.com/?q=

    正如jjclarkson所说,但你也需要逃离你地址中的空格 .

    所以这:

    <a class='thickbox' href='http://maps.google.com/?q=http://maps.google.com/?q=1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003'>
       Map
    </a>
    

    成为这个:

    <a class='thickbox' href='http://maps.google.com/?q=http://maps.google.com/?q=1200%20Pennsylvania%20Ave%20SE%2C%20Washington%2C%20District%20of%20Columbia%2C%2020003'>
       Map
    </a>
    

    网址需要转义大多数非字母数字字符 .

相关问题