const scene = viewer.scene; const promise = scene.open('http://xxxx.xxx.com/iserver/services/3D-ZJGYJ3DAll/rest/realspace');
以上代码是加载全部的场景。
加载指定的图层
var promise = scene.addS3MTilesLayerByScp('http://1xxxx.xxx.com/iserver/services/3D-ZJGYJ3DQY/rest/realspace/datas/DHSWSZSS/config', { name: "东华室外市政设施", }); promise.then(function (layer: { style3D: any; }) { var style = new Cesium.Style3D(); style.bottomAltitude = 5; layer.style3D = style; }); var layer = scene.layers.find('东华室外市政设施');//查找图层 layer._visible = false;//隐藏图层 console.log(layer);
图层控制器
const addLayer = (checkedKeys, viewer, layersData) => { if (!layersData) return false; const scene = viewer.scene; // if (checkedKeys.length <= 0) return false; //找到未选中的图层 let newArr = layersData.filter(function (item) { return checkedKeys.every(function (item1) { return item.layerid != item1; }); }); //找到选中的图层 const result = layersData.filter((item) => { return (checkedKeys.some(f => f === item.layerid)); }); result.forEach(element => { let layer = scene.layers.find(element.name); if (layer) { const { lat, lon } = layer; viewer.camera.flyTo({ destination: new Cesium.Cartesian3.fromDegrees(lon, lat, 500), duration: 0.2, }); layer._visible = true; return false; } else { let promise = scene.addS3MTilesLayerByScp(`${element.url}/${element.layername}/config`, { name: element.name, }); promise.then(function (layer) { //查询模型的数据 layer.setQueryParameter({ url: window.BASECONFIG.DISPLAY_BAIMO_DATA, dataSourceName: "ZJGDHXNY2DData", dataSetName: layer._name, // isMerge: true, // keyword: 'SmID' }); layer.visible = true; }); } }); newArr.forEach(item => { let layer = scene.layers.find(item.name); if (layer) { layer._visible = false; // layer.refresh(); } }); }; //设置弹窗 var infoboxContainer = document.getElementById("bubble"); viewer.customInfobox = infoboxContainer; viewer.pickEvent.addEventListener(function (feature) { if (feature) { bubble.style.display = "block"; // eslint-disable-next-line react/no-render-return-value ReactDOM.render(<DescContainer feature={feature} />, bubble); } });
发表评论
侧栏公告
寄语
譬如朝露博客是一个分享前端知识的网站,联系方式11523518。
热评文章
标签列表
热门文章
友情链接