1
我想創建一個聯繫我們頁面的引導框架,我有一行分爲兩列。在左側,我有一個包含加載谷歌地圖的iframe的列。在右側,我有一個包含4個辦公室地址的列。默認情況下,iframe默認加載總部地圖。使用jQuery在iframe中顯示多個地圖
我希望能夠點擊其中一個辦公室和iframe內容更改以顯示相關的映射信息。
在頁面上的HTML如下: -
<section id="contact-info">
<div class="center">
<h2>How to Reach Us?</h2>
<p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
</div>
<div class="gmap-area">
<div class="container">
<div class="row">
<div class="col-sm-5 text-center">
<div class="gmap">
<iframe id="gmaps" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=JoomShaper,+Dhaka,+Dhaka+Division,+Bangladesh&aq=0&oq=joomshaper&sll=37.0625,-95.677068&sspn=42.766543,80.332031&ie=UTF8&hq=JoomShaper,&hnear=Dhaka,+Dhaka+Division,+Bangladesh&ll=23.73854,90.385504&spn=0.001515,0.002452&t=m&z=14&iwloc=A&cid=1073661719450182870&output=embed"></iframe>
</div>
</div>
<div class="col-sm-7 map-content">
<ul class="row">
<li class="col-sm-6">
<address>
<h5 id="office_01">Head Office</h5>
</address>
<address>
<h5 id="office_02">Office 2</h5>
</address>
</li>
<li class="col-sm-6">
<address>
<h5 id="office_03">Office 3</h5>
</address>
<address>
<h5 id="office_04">Office 4</h5>
</address>
</li>
</ul>
</div>
</div>
</div>
</div>
</section> <!--/gmap_area -->
<script src="js/mapmover.js"></script>
jQuery的如下: -
$(document).ready(function(){
$("#office02").click(function(){
$("#gmaps").attr("src","https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=JoomShaper,+Dhaka,+Dhaka+Division,+Bangladesh&aq=0&oq=joomshaper&sll=37.0625,-95.677068&sspn=42.766543,80.332031&ie=UTF8&hq=JoomShaper,&hnear=Dhaka,+Dhaka+Division,+Bangladesh&ll=23.73854,90.385504&spn=0.001515,0.002452&t=m&z=14&iwloc=A&cid=1073661719450182870&output=embed");
});
});
理想我想活躍的地圖,而不是靜態的圖像,但我得到的是一個空白的框。如果我將iframe的「src」替換爲正常的網頁,它就可以工作。我猜這是與谷歌地圖加載到頁面的方式有關,但這超出了我的正常範圍,因爲我對jQuery知之甚少。
我最初使用的html的,而不是在jQuery的.attr嘗試,但它似乎不喜歡「的源,這是有道理的......
任何人有任何意見或例子我可以看?
我會研究這個。實際上,這聽起來像是一個更好的處理問題的方法。感謝您指點我正確的方向 – Nemtex