多次使用多屏对比功能给页面添加图形,然后报错WARNING: Too many active WebGL contexts. Oldest context will be lost.
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/72d92573deb493129b8ca609e3b321ff.gif#pic_center)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/bd9fd0fccfce145f393826735cc0de8c.png)
<template>
<div class="grid-container" v-show="this.$store.getters._getDefaultDpdbVisible">
<div id="dpdb_id1" class="item1"></div>
<div id="dpdb_id2" class="item2"></div>
<div id="dpdb_id3" class="item3"></div>
<div id="dpdb_id4" class="item4"></div>
</div>
</template>
<script>
import MapView from '@arcgis/core/views/MapView';
export default {
data() {
return {
aa: '',
dpdbViews: [],
};
},
watch: {
'$store.getters._getDefaultDpdbVisible'(newVal, oldVal) {
console.log('如果v-show为真,就初始化地图');
console.log('新值: ' + newVal + ' ' + '旧值: ' + oldVal);
this.initView();
if (oldVal) {
console.log('aa');
}
},
},
mounted() {
},
methods: {
async initView() {
this.dpdbViews = [];
const yuanshiView = this.$store.getters._getDefaultMapView;
for (let i = 1; i < 5; i++) {
const dpdbView = new MapView({
map: yuanshiView.map,
zoom: yuanshiView.zoom,
extent: yuanshiView.extent,
container: 'dpdb_id' + i,
});
dpdbView.ui.components = [];
this.dpdbViews.push(dpdbView);
}
this.dpdbViews.forEach((view) => {
console.log(view);
var fullExtent = null;
console.log(this);
view.on('mouse-wheel', (e) => {
console.log(this);
fullExtent = view.extent;
this.dpdbViews.forEach((nview) => {
nview.extent = fullExtent;
console.log(this);
});
});
view.on('drag', (e) => {
fullExtent = view.extent;
this.dpdbViews.forEach(function (nview) {
nview.extent = fullExtent;
});
});
});
},
},
};
</script>
<style>
.grid-container {
position: absolute;
display: grid;
height: 100%;
width: 100%;
background-color: aqua;
grid-template-columns: auto auto;
grid-gap: 5px;
background-color: rgb(3 8 41);
padding: 0px;
}
.grid-container > div {
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
padding: 0 0;
font-size: 30px;
}
</style>