我想在向导表单上制作谷歌地图,但地图无法正确加载,只显示一半。我尝试调整大小,但地图仍然无法完全显示。谢谢
<div class="row">
<div class="col-sm-6">
<div id="gmaps" style="width: 100%; height: 417px;"></div>
</div>
</div>
我使用引导响应。
$(function ()
{
$("#wizard").steps({
headerTag: "h2",
bodyTag: "section",
transitionEffect: "slideLeft"
});
});
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644)
};
map = new google.maps.Map(document.getElementById('gmaps'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addDomListener(window, "resize", resizingMap());
$('#wizard').on('changed.fu.wizard', function(){
resizeMap();
});
function resizeMap(){
if(typeof map == "undefined") return;
setTimeout(function(){resizingMap();} , 400);
}
function resizingMap(){
if(typeof map == "undefined") return;
var center = map.getCenter();
google.maps.event.trigger(map,"resize");
map.setCenter(center);
}