gpt4 book ai didi

javascript - GeoExt MapPanel 完全加载后正确删除 LoadMask

转载 作者:行者123 更新时间:2023-11-30 06:44:43 25 4
gpt4 key购买 nike

我想在整个页面上设置一个 mask ,直到整个页面完全加载后才将其移除。更具体地说,我有一个用 OpenLayers 和 GeoExt 创建的 map ,我正在尝试使用 ExtJS loadMask。但是,除了使用我不想使用的手动 setTimeout 之外,我找不到任何其他方法来执行此操作。我宁愿只有在页面完全加载时才删除掩码。我尝试在 openLayers map 以及 windows.onload 等上使用“loadend”事件:

我的 map 和 loadMask 配置:

var mask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
mask.show();

Ext.onReady(function() {
var options = {
controls: [new OpenLayers.Control.Navigation()],
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
units: 'm',
allOverlays: false
}

var map = new OpenLayers.Map(options);

map.events.register("loadend", map , function() {
mask.hide(); alert('howdy');
});

var mapPanel = new GeoExt.MapPanel({
title: "Map",
map: map,
id: 'mapPanel',
layerStore: map.layers,
//Set the map to be centered at specified longitude/latitude, transform our layers (SRID=4326) to display properly on Google
//base layers (SRID=900913)
center: new OpenLayers.LonLat(95.20, 30.34).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")),
zoom: 7,
region: "center",
tbar: [measureLength, '-', measureArea, '-'],
bbar: [
{
xtype: "label",
text: "Scale = 1 : "
}

],
items: [{
xtype: "gx_zoomslider",
vertical: true,
height: 300,
aggressive: true,
x: 10,
y: 20,
plugins: new GeoExt.ZoomSliderTip()
}]
});

似乎此事件从未发生过,因为我从未收到过警报消息。我真的很想让这个工作,其他尝试是:

window.onload = mask.hide();

在 Ext.onReady 之后和 </body> 结束时标签,但是在 map 加载完成之前掩码被隐藏了。谁能分享一些见解,我将不胜感激!

最佳答案

像这样在项目之后添加事件 'onMapReady':

onMapReady: function() {
Ext.getBody().unmask();
}

关于javascript - GeoExt MapPanel 完全加载后正确删除 LoadMask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7933824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com