选项卡内容(谷歌地图)初始化问题
我想创建多个动态选项卡,每个选项卡中都有不同的谷歌地图。而且地图不应在每次单击选项卡时初始化...我的编码在下面...实际上我的问题是每次单击选项卡时都会初始化地图。 ..如何解决这个问题...
//动态创建选项卡的函数
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');在选项卡的单击事件中..但这也不起作用。
I want to create Multiple dynamic Tabs with different google maps in each tabs.Also the the map should not initialize every time Tab clicks...My codings are below... Actually my problem is the Map initialized every time i click on Tabs...How to clear this issue...
//Function to create Tab dynamically
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);
}
Also I have tried google.maps.event.trigger(map, 'resize'); in click event of Tabs..But this also not working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论