0
我有一個嵌入在jQuery UI對話框中的谷歌地圖。谷歌地圖的jQuery UI對話框只能工作一次
它按預期工作,但只有一次,直到頁面刷新。
這裏發生了什麼:
- 一個鏈接,用戶點擊,在彈出的打開和地圖(巴甫洛達爾!)加載
- 用戶關閉彈出的
- 用戶點擊再次鏈接:彈出窗口打開,它在左下角顯示「Google」,但地圖區域保持空白。
- 用戶刷新頁面,一切都變爲 恢復正常。
這裏是我的功能:
$(document).ready(function() {
//avoid conflict with bootstrap css tooltips
var bootstrapButton = $.fn.button.noConflict();
$.fn.bootstrapBtn = bootstrapButton;
//button click event handler
$("#popMap").click(function (ev) {
//create map to draw address location
var pavlodar = {lat: 52.3200561, lng: 76.9082336};
var map = new google.maps.Map(document.getElementById('mapcanvas'), {
zoom: 18,
center: pavlodar,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
//establish ideal sizes
var w = screen.width;
var h = screen.height;
if(w > h){
var dw = w * 0.5;
var dh = h * 0.5;
} else {
var dw = w * 0.8;
var dh = h * 0.6;
}
// create the map point
var marker = new google.maps.Marker({ map: map, position: pavlodar });
//calling the dialog
$("#mapcanvas").dialog({ title: "наше место нахождения", maxWidth: dw, maxHeight: dh, height: dh, width: dw, modal: false, position: { my: "center", at: "center", of: window }});
//stop the browser interpreting the click
ev.preventDefault();
ev.stopPropagation();
});
});
我不知道這是不是隻是一些限制,對谷歌的結束,或者有什麼錯我的代碼。
任何想法可能是什麼問題?
我怎麼看這可能工作後對話,但因爲它是對話框在頁面加載時打開,沒有地圖( – nico
)使用'autoOpen:false' .Check [this](http://jsfiddle.net/cshudc91)out – Viney