2009-08-20 94 views
1

我正在使用jQuery的thickbox,並希望將其用於Google地圖鏈接。Thickbox和谷歌地圖鏈接

我看到的方法對我使用的鏈接(URL)格式不起作用。

的URL格式:哥倫比亞

http://maps.google.com/?q=1200賓夕法尼亞大街SE,華盛頓區,20003

所以,如果我用這個:

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

它只是重定向到Google地圖頁面,而不是用Google地圖打開彈出窗口。我試圖在Ajax調用追加到URL

?height=300&width=300 

但它不工作

回答

2

我發佈了一個單獨的答案,因爲有一種不同的方式來實現這一點 - 沒有整個谷歌地圖頁面在Thickbox中 - 我們只是想要地圖本身。

此方法將地圖置於頁面上的隱藏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。 t=h使之成爲衛星地圖。您可以將這些添加到原始方法中的鏈接中(直接打開iframe),但爲Google地圖和Thickbox混合使用URL參數似乎會讓它失去作用。

+0

這正是我需要的,謝謝!從我投票 – 2012-05-16 13:46:04

0

也許是因爲你有這樣的一部分:

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

在你的鏈接兩次?

+0

修復了錯字,但這不是問題的一部分,只是一個錯字 – 2009-08-20 17:34:46

0

您可能需要刪除你的雙

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> 

網址都需要有大多數非字母數字字符轉義。

+0

修正了錯字,但這不是問題的一部分,只是一個錯字。至於空間,我可以添加%20,但鏈接仍然是 – 2009-08-20 17:35:33

2

要在ThickBox的iframe中打開網址,就需要追加給你的網址:

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

見iFrame內容的ThickBox說明。

你確實應該刪除雙http://maps.google.com/?q=,但它應該仍然工作,如果你不逃避空間(這不是很好的做法)。