我要进行一个地图切换的操作 代码如下 每次if判断的时候我都进行了scene.layers.removeAll(); 操作 按理来说网页就会消除资源就不会卡
可是为什么3秒之后网页基本上就卡死了 请问这里是消除语句的问题 还是代码结构的问题 有什么能够解决的办法嘛
setInterval(function () {
{
getDataFromBack();
}
}, 10000);
//请求后端接口,实现动态添加点,并获取获取地图切换后的url
function getDataFromBack() {
$.ajax({
type: "get",
url: "/find",
async: false,//同步,为了获取返回值
dataType: "json",
data: {},
success: function (data) {
add(data[0].x, data[0].y, data[0].z);
// console.log(data);
mapId = data[0].mapID;
floor = data[0].floor;
Xcord = data[0].x;
url = "";
if (mapId == 1) {
if (floor == 1) {
url = "http://10.108.251.36:8899/iserver/services/3D-f1-f1/rest/realspace";
var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;
var promise = scene.open(url);
scene.layers.removeAll();
console.log("移除成功");
} else if (floor == 2) {
url = "http://10.108.251.36:8899/iserver/services/3D-f2-f2/rest/realspace";
} else if (floor == 3) {
url = "http://10.108.251.36:8899/iserver/services/3D-f3-f3/rest/realspace";
} else if (floor == 4) {
url = "http://10.108.251.36:8899/iserver/services/3D-f4-f4/rest/realspace";
}
}
},
});
return url;
}