It's about VectorImage: https://openlayers.org/en/latest/apidoc/module-ol_layer_VectorImage-VectorImageLayer.html
(关于VectorImage: https ://openlayers.org/en/latest/apidoc/module-ol_layer_VectorImage-VectorImageLayer.html)
I can't get it to work properly.
(我无法使其正常工作。)
For testing purposes, I add a fullscreen div on top of my map in the prerender event and remove this div in postrender event. (为了进行测试,我在prerender事件中在地图顶部添加了全屏div,并在postrender事件中删除了该div。)
In the end, I want to add a spinning loading animation in the middle of my div and block map interaction, if rendering process is going on. (最后,如果渲染过程正在进行中,我想在div和块图交互的中间添加一个旋转的加载动画。)
I have two divs, one for the map and one for the loading indicator:
(我有两个div,一个用于地图,另一个用于加载指标:)
<div id="map" class="map">
<div id="test" class="overlay"></div>
My css styles:
(我的CSS样式:)
.map {
height: 100%;
width: 100%;
}
html, body {margin:0;padding:0;height:100%}
div {width:100px;height:100%;}
.overlay {
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
z-index:1000;
background-color:red;
}
Global reference
(全球参考)
var myDiv = document.getElementById("test");
And the events
(和事件)
vectorLayer.on('postrender', function(event) {
myDiv.remove();
console.log('post');
});
vectorLayer.on('prerender', function(e) {
document.getElementsByTagName('body')[0].appendChild(myDiv);
console.log('pre');
});
With that code I see my div at the beginning.
(使用该代码,我会在开始时看到div。)
When my map is ready, the div is being removed. (当我的地图准备好时,将删除div。)
But with any other interaction my div never beeing added, even if I can clearly see the logs in the console, that the events are fired. (但是,即使我可以在控制台中清楚地看到日志,也无法添加任何其他交互,即使我在控制台中看到日志,也不会触发事件。)
ask by R. Kut translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…