<style type="text/css">
/*css控制地图大小自动充满整个窗口*/
html{height:100%}
body{height:100%;margin:0px;padding:0px}
#map_canvas{width:100%;height:100%}
@media print {#map_canvas {height: 950px;}}
</style>

在窗口中若有查询栏目,需要显示隐藏的时候,写一个方法动态设置地图div的高度,放在body的onresize事件里执行
//自动改变地图的高度
 function changeMapHeight() { 
     var qheight=$("#querytxt").height();
    if(qheight==1) { 
      qheight=80; 
    }else { 
      qheight=1; 
    } 
    var totalheight=$(window).height();
    var nowHeight=totalheight-qheight-20; // 
    alert("查询:"+qheight+"body:"+$(document.body).height()+"浏览器文档:"
            +$(document).height()+"浏览器:"+$(window).height()+"地图:"
            +nowHeight+"可见区域:"+document.body.clientHeight);
    $("#map_canvas").height(nowHeight);
 }
 window.onresize=changeMapHeight;

 

相关文章:

  • 2021-12-21
  • 2021-12-21
  • 2021-12-23
  • 2021-12-23
  • 2021-06-12
  • 2021-11-16
猜你喜欢
  • 2022-12-23
  • 2021-04-03
  • 2021-12-12
  • 2021-12-21
  • 2021-12-12
  • 2021-12-12
  • 2021-12-21
相关资源
相似解决方案