日期:2014-05-16  浏览次数:20323 次

用选项卡 切换掉隐藏的百度地图 百度地图不显示

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Slide</title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&amp;ak=6066cf2819dbd803b5a1799007d7e3e0 "></script>
<script type="text/javascript"> 
$(document).ready(function(){
$(function(){
var $div_li =$("div.div_head ul li");
$div_li.click(function(){
$(this).addClass("active")            
.siblings().removeClass("active"); 
var index =  $div_li.index(this);  
$("div.div_content > div")   
.eq(index).show()   
.siblings().hide(); 
}).hover(function(){
$(this).addClass("hover");
},function(){
$(this).removeClass("hover");
})
})
});
</script>
  <script type="text/javascript">

// 百度地图API功能
var map = new BMap.Map("allmap");
var point = new BMap.Point(116.404, 39.915);
map.centerAndZoom(point, 15);
var marker = new BMap.Marker(point);  // 创建标注
map.addOverlay(marker);              // 将标注添加到地图中
marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画

</script>   
<style type="text/css"> 
*{
margin:0;
padding:0;
}
li{
list-style:none;
}
.div{
width:735px;
float:left;
border:1px solid #DCDCDC;
}
.div_head{
width:735px;
float:left;
}
.div_head li{
width:120px;
height:35px;
background:#CCC;
float:left;
cursor:pointer;
}
.div_head .active{
background:#00BCF3;
}
.div_content,.div_con{
width:735px;
float:left;
}
.div_con{
display:none;
}
</style>
     
<body>
<div class="div">
 <div class="div_head">
  <ul>
   <li class="active">数字</li>
   <li>地图</li>
  </ul>
 </div>
 <div class="div_content">
  <div class="div_con" style="display:block">11111111</div>
  <div class="div_con">
     <div style="width:735px;height:415px;"id="allmap"></div>
  </div>
 </div>
</div>
</body>
</html>


百度地图 刚开始是隐藏的 用选项卡 切换到百度地图的时候 地图不显示