Twitter bootstrap 引导模式中的google地图无法正常工作
几天来,我一直试图在bootstrap模式中显示google地图,我在这里搜索了讨论这个话题的所有答案,但到目前为止,没有任何东西对我有用。 我知道我必须在模态打开后使用resize触发器,事实上我使用了它,但对我来说似乎没有任何效果,这非常令人沮丧。 请帮忙 以下是我使用的代码:Twitter bootstrap 引导模式中的google地图无法正常工作,twitter-bootstrap,google-maps,bootstrap-modal,google-maps-mobile,google-maps-embed,Twitter Bootstrap,Google Maps,Bootstrap Modal,Google Maps Mobile,Google Maps Embed,几天来,我一直试图在bootstrap模式中显示google地图,我在这里搜索了讨论这个话题的所有答案,但到目前为止,没有任何东西对我有用。 我知道我必须在模态打开后使用resize触发器,事实上我使用了它,但对我来说似乎没有任何效果,这非常令人沮丧。 请帮忙 以下是我使用的代码: <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></scri
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var map;
myLatlng = new google.maps.LatLng(32.0260053,34.8987034);
function initialize() {
var myOptions = {
zoom: 14,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'),
myOptions);
$('.myMapModal').on('show.bs.modal', function() {
google.maps.event.trigger(map, 'resize');
return map.setCenter(myLatlng);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
var映射;
myLatlng=new google.maps.LatLng(32.0260053,34.8987034);
函数初始化(){
变量myOptions={
缩放:14,
中心:myLatlng,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
map=new google.maps.map(document.getElementById('map-canvas'),
肌肽);
$('.myMapModal').on('show.bs.modal',function()){
google.maps.event.trigger(映射,'resize');
返回地图设置中心(myLatlng);
});
}
google.maps.event.addDomListener(窗口“加载”,初始化);
HTML:
<div class="modal myMapModal fade" id="myMapModal" >
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">#f16#</h4>
</div>
<div class="modal-body map-modal">
<div class="container">
<div class="row">
<div id="map-canvas" style="width: 500px; height: 480px;"></div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">סגירה</button>
</div>
</div>
</div>
</div>
&时代;
#f16#
סגירה
看看这个:可以为您服务吗
$("#myMapModal").ready(function() {
$(window).resize(function() {
google.maps.event.trigger(map, 'resize');
});
$('#myMapModal').modal('show');
google.maps.event.trigger(map, 'resize');
return map.setCenter(myLatlng);
});
我用下面的方法得到了它,它可能会帮助别人
BootstrapDialog.show({
title: 'Point on Map',
message: ''<div id="selction_map"></div>'',
onshown: function(dialogRef){
initMap();
}
});
BootstrapDialog.show({
标题:“地图上的点”,
消息:“”,
onshown:函数(dialogRef){
initMap();
}
});