[英]google map not load into bootstrap modal
我正在使用模態引導程序,需要在其中加載googlemap,但是我只是照常進行加載,控制台顯示了正在加載的地圖,但是元素檢查顯示了必須將地圖加載為空的元素,例如圖片
我的地圖使用的代碼是
var map;
var drawingManager;
var selectedShape;
function initializeMap() {
var mapOptions = {
center : new google.maps.LatLng(-16.4237766667, -71.54262),
zoom : 15,
mapTypeId : google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("mapCanvas"),
mapOptions);
console.debug(map);
}
$(document).ready(
function() {
initializeMap();
$('#createleaf').click(function() {
$('#modalFence').modal('show');
});
$('#modalFence').on('shown',function(event) {
//console.debug(map);
google.maps.event.trigger(map, "resize");
map.setZoom( map.getZoom() );
var modal = $(this);
modal.css('margin-top',(modal.outerHeight() / 2) * -1)
.css('margin-left',(modal.outerWidth() / 2) * -1);
return this;
});
});
還有一件事,我只是嘗試在模態之外創建地圖,我的意思是在頁面上,它運行良好,問題僅在於模態
我的完整代碼在外部鏈接上 ,以免發布時間過長
非常感謝
我只是發現錯誤,它是一種打字,我注意到粘貼箱中的第246-256行包含具有相同id映射容器的模式,這就是為什么我的模式未顯示地圖的原因它被裝載到第一個具有相同ID坦克的集裝箱上
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.