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

本文介绍了一种在网页中调整地图组件尺寸的方法。通过监听resize事件并使用JavaScript代码更新地图节点的大小,确保地图组件能够正确地填充其父容器的空间。这种方法适用于地图组件嵌套在dijit/layout节点的情况。

相关讨论请见:
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'
    });
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值