我想在每个标签中创建具有不同谷歌地图的多个动态标签。而且,每次标签点击时地图都不应该初始化...我的编码在下面...实际上我的问题是每次点击时都会初始化地图在标签上...如何清除此问题......
//动态创建Tab的功能
function addTab(link,name) {
$("#content").append("<div id='" + $(link).attr("value") + "_content'style='width:100%;height:100%'></div>");
var mid = $(link).attr("value")+"_content";
tab1map(mid);
$("#" + $(link).attr("value") + "_content").show();
}
//function for click event of Tabs
$('#tabs a.tab').live('click', function() {
$("#content div").hide();
$("#" + contentname).show(); // Here "contentname" is the id of the above Div tag when creating Tab
tab1map(contentname); //Here the Map function called again
// Here We should not call this map function again....the Map will Display with existing content in the $("#" + contentname).show(); itself..but it is not displayed....
}
// Map Function
function tab1map(mid) {
var map = new google.maps.Map(document.getElementById(mid), myOptions);
}
我也试过google.maps.event.trigger(map,'resize');在Tabs的点击事件中..但这也无效。