【发布时间】:2014-01-11 20:36:08
【问题描述】:
我研究了很多,似乎很多人在这里遇到了和我一样的问题,但我不知道如何解决它。
基本上,我在隐藏的引导选项卡中初始化谷歌地图。当我单击药丸使选项卡可见时,仅显示一小部分地图。
据我所知,这是因为地图是在隐藏元素中初始化的。所以我需要在选项卡变得可见后才初始化地图。
我已经尝试过,我已经尝试过,但我无法正确获取代码。任何帮助都会很重要-我如何使地图仅在选项卡可见后才执行?
提前致谢
<!-- this is the hidden tab-->
<div class="tab-pane map-pane" id="map<?php echo $country_slug; ?>">
<div class = "row">
<div class = "col-md-12">
<div id="map-canvas" class = "map-canvas"></div>
</div>
</div>
<!--and here is the map which executes inside the hidden tab-->
<!--how can i cause this script to delay execution until the tab is shown?-->
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(22.39813,114.10943),
zoom: 8
};
var map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
【问题讨论】:
标签: jquery google-maps-api-3 twitter-bootstrap-3