【发布时间】:2015-12-11 15:24:17
【问题描述】:
我在 Bootstrap 轮播中有几张 Google 地图作为幻灯片。问题是只有初始活动的地图才能正常工作。所有其他的都行不通。
我搜索了类似的问题,人们似乎建议使用函数来调整页面大小。但我对 Javascript 真的很陌生,不知道这对我的多张地图有什么作用。我已经尝试了很多,但它总是坏掉。真的需要帮助。
我该怎么办?我实际上有更多幻灯片,但我认为可能太多,无法放上来。
我的部分 html 在这里:
<div class="carousel" id="intro">
<ol class="carousel-indicators">
<li data-target="#intro" data-slide-to="0" class="active"></li>
<li data-target="#intro" data-slide-to="1"></li>
<li data-target="#intro" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<div class="carousel-content">
<div class="carousel-caption">
<h2>Spring Dawn at Su Causeway</h2>
<img src="img/su.jpg" />
<p>Su Shi, an outspoken official as well as a renowned painter, poet and art theorist, was made prefect of Hangzhou in 1089 during the Northern Song Dynasty. By that time, West Lake had shrunken to half its previous size due to increased land usage around the lake and was choked with weeds.</p>
<div id="sudi"></div>
</div>
</div>
</div>
<div class="item">
<div class="carousel-content">
<div class="carousel-caption">
<h2>Lotus in the Breeze at Crooked Courtyard</h2>
<img src="img/qu.jpg" />
<p>The imperial family of the Southern Song Dynasty kept their imperial brewery, Quyuan, close to the banks of West Lake in their capital city, Hangzhou. When the gentle summer breeze blew through lotuses kept in the lake near the brewery, it mixed with the smells of alcohol and was said to make even those not drinking feel intoxicated.</p>
<div id="quyuan"></div>
</div>
</div>
</div>
<div class="item">
<div class="carousel-content">
<div class="carousel-caption">
<h2>Melting Snow on Broken Bridge</h2>
<img src="img/duan.jpg" />
<P>In keeping with the seasonal theme, Lingering Snow on Broken Bridge takes in the view from the arched Broken Bridge, located at the eastern end of the Bai Causeway, the day after snow has fallen. To the northwest, the view takes in the snow-covered buildings and hill at Gu Shan while the rest of the lake stretches out in black contrast to the south, with the snowy white hills around it.</P>
<div id="duanqiao"></div>
</div>
</div>
</div>
</div><!-- carousel-inner -->
</div>
我的谷歌地图相关代码在这里:
function initMap() {
var mapOptions = {
sudi: {
center: {lat: 25.7823072, lng: -80.3011205},
zoom: 9,
mapTypeId: google.maps.MapTypeId.ROADMAP, // SATELLITE
mapTypeControl: false
},
quyuan: {
center: {lat: 26.1410956, lng: -80.2200135},
zoom: 9,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
},
duanqiao: {
center: {lat: 25.7823072, lng: -80.3011205},
zoom: 9,
mapTypeId: google.maps.MapTypeId.ROADMAP, // SATELLITE
mapTypeControl: false
},
}
var sudiMap = new google.maps.Map(document.getElementById("sudi"), mapOptions.sudi);
var quyuanMap = new google.maps.Map(document.getElementById("quyuan"), mapOptions.quyuan);
var duanqiaoMap = new google.maps.Map(document.getElementById("duanqiao"), mapOptions.duanqiao);
};
【问题讨论】:
标签: javascript twitter-bootstrap google-maps