2014-12-23 180 views
1

我有一個奇怪的問題,我添加到地圖的谷歌地圖是一路縮小,我找不到原因。谷歌地圖嵌入不縮放

有問題的頁面在https://workland.ca/en/,然後您轉到網站的頁腳並單擊聯繫人。以下是我使用的iframe。我試了& z = 15沒有效果。

<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d2795.9215847167884!2d-73.56997780251234!3d45.51165713370363!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4cc91a4bbe13b0df%3A0xc06c2aa42d3df87c!2s51+Rue+Sherbrooke+O%2C+Montr%C3%A9al%2C+QC+H2X+1X2!5e0!3m2!1sen!2sca!4v1419350169105&z=15" 
         style="width:100%;height:230px; border:0" frameborder="0"></iframe> 

又一個細節 地圖工作正常,如果我表現出這樣的模式,

$(function() { 
     $('#modalContact').modal('show'); 
    }) 

奇怪的是在頁面加載後,我點擊

<a onclick=" $('#modalContact').modal('show')" href="#">Contact</a> 

的地圖再次縮小

我發現解決方案iframe必須在模態後加載顯示

<script> 
    $(
     function() { 
      $('#modalContact').on('shown.bs.modal', 
       function() { 
        $(this) 
         .find("#the_map") 
         .html(' <iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d2795.9215847167884!2d-73.56997780251234!3d45.51165713370363!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4cc91a4bbe13b0df%3A0xc06c2aa42d3df87c!2s51+Rue+Sherbrooke+O%2C+Montr%C3%A9al%2C+QC+H2X+1X2!5e0!3m2!1sen!2sca!4v1419350169105&z=20" style="width:100%;height:230px; border:0" frameborder="0"></iframe>') 
       } 
      ) 
     } 
    ) 
</script> 
+0

我相信它和縮放= 15,而不是&Z = 15 – Bioto

回答

1

我發現,提出變焦的問題,因爲iframe的前 引導模特秀的方法調用得到加載

你可以解決它像後續: 1)將iframe內容加入變量中

<script> 
    var htm ='<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d2795.9215847167884!2d-73.56997780251234!3d45.51165713370363!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4cc91a4bbe13b0df%3A0xc06c2aa42d3df87c!2s51+Rue+Sherbrooke+O%2C+Montr%C3%A9al%2C+QC+H2X+1X2!5e0!3m2!1sen!2sca!4v1419350169105&amp;zoom=1" style="width:100%;height:230px; border:0" frameborder="0"></iframe>'; 
</script> 

2)取模態體一個DIV與接觸寬度和高度固定的和大於ifrmae寬度和高度等

<div style="width:500px;height:250px;" class="container">       
</div> 

3)點擊你要首先顯示彈出,然後填充容器的iframe像:

<a onclick=" $('#modalContact').modal('show');$('.container').html(htm);" href="#">Contact</a> 

And your issue can solve. 
+0

燁那是什麼是令人 – ericsicons

0

使用此:

<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d2795.9215847167884!2d-73.56997780251234!3d45.51165713370363!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4cc91a4bbe13b0df%3A0xc06c2aa42d3df87c!2s51+Rue+Sherbrooke+O%2C+Montr%C3%A9al%2C+QC+H2X+1X2!5e0!3m2!1sen!2sca!4v1419350169105&zoom=15" style="width:100%;height:230px; border:0" frameborder="0"></iframe> 
+0

都能跟得上沒有工作, – ericsicons