我想在整个页面上有一个面具,这是不会被删除,直到整个页面已完全加载。更具体地说,我有一个用OpenLayers和GeoExt创建的地图,我正在尝试使用ExtJS loadMask。但是,除了使用我不想使用的手动setTimeout之外,我找不到任何其他方法来完成此操作。我更希望只有在页面完全加载的情况下才去掉掩码。我试着在openLayers地图和windows.onload上使用'loadend‘事件:
我的地图和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>标记的末尾,然后在地图加载完成之前隐藏掩码。有没有人能分享一些见解,我将非常感谢!
发布于 2012-07-06 09:38:01
在项目后面添加事件'onMapReady‘,如下所示:
onMapReady: function() {
Ext.getBody().unmask();
}https://stackoverflow.com/questions/7933824
复制相似问题