在arcgis javascript 中map地图的div 总是显示高度400的问题

来源:互联网 发布:卷积矩阵运算法则 编辑:程序博客网 时间:2024/05/16 10:18

相关讨论请见:
https://geonet.esri.com/thread/107699
If the map node is being created in a dijit/layout/* node then you can listen once to the ‘resize’ event so you can call map.reposition() and map.resize(). This might not help depending on the css rules so you might have to reset the node size back to 100% and then call reposition and resize. Alternatively you could use dom-geometry.position(…) to get the current node size. However, listening to the ‘resize’ event won’t help if you’re creating the map in just a div node as it won’t have a resize event. To find the parent dijit you can use registry.getEnclosingWidget(…) and pass in the map.root node. This will traverse up the parent dom nodes until it finds a dijit. Then hopefully it will be a dijit with a ‘resize’ event you can listen to once.

解决办法 :
在页面载入后,调用如下js代码,重新进行resize

$(document).ready(function () {    resizeDiv();});function resizeDiv() {    var vph = $(window).height();    $('#map_div').css({        'height': vph + 'px',        'width': vpw + 'px'    });}
0 0
原创粉丝点击