| | |
| | | } |
| | | }, |
| | | handleOpenClick() { |
| | | // let that = this; |
| | | sgworld.Creator.SimpleGraphic.edit(true, { editProp: true }); |
| | | let fileInput = document.querySelector('.file'); |
| | | fileInput.onchange = function (evt) { |
| | | let files = evt.target.files; |
| | | if (files.length > 0) { |
| | | let file = evt.target.files[0]; |
| | | sgworld.Creator.addKmlLayer('kml数据', file, true); |
| | | // let fileReader = new FileReader(); |
| | | // fileReader.readAsDataURL(file); |
| | | // fileReader.onload = () => { |
| | | // sgworld.Viewer.dataSources |
| | | // .add( |
| | | // Cesium.KmlDataSource.load(fileReader.result, { |
| | | // camera: sgworld.Viewer.scene.camera, |
| | | // canvas: sgworld.Viewer.scene.canvas, |
| | | // }) |
| | | // ) |
| | | // .then((KmlDataSource) => { |
| | | // console.log(KmlDataSource); |
| | | // // let entities = kmlDataSource.entities; |
| | | // }); |
| | | // }; |
| | | let fileReader = new FileReader(); |
| | | fileReader.readAsDataURL(file); |
| | | fileReader.onload = () => { |
| | | var kmlOptions = { |
| | | camera: sgworld.Viewer.scene.camera, |
| | | canvas: sgworld.Viewer.scene.canvas, |
| | | clampToGround: true, |
| | | }; |
| | | var geocachePromise = Cesium.KmlDataSource.load( |
| | | fileReader.result, |
| | | kmlOptions |
| | | ); |
| | | geocachePromise.then(function (dataSource) { |
| | | var geocacheEntities = dataSource.entities.values; |
| | | |
| | | for (var i = 0; i < geocacheEntities.length; i++) { |
| | | var entity = geocacheEntities[i]; |
| | | |
| | | sgworld.Viewer.entities.add(entity); |
| | | } |
| | | }); |
| | | // sgworld.Viewer.dataSources |
| | | // .add( |
| | | // Cesium.KmlDataSource.load(fileReader.result, { |
| | | // camera: sgworld.Viewer.scene.camera, |
| | | // canvas: sgworld.Viewer.scene.canvas, |
| | | // }) |
| | | // ) |
| | | // .then((KmlDataSource) => { |
| | | // console.log(KmlDataSource); |
| | | // // let entities = kmlDataSource.entities; |
| | | // }); |
| | | }; |
| | | } |
| | | // fileInput.value = null; |
| | | }; |
| | |
| | | this.$bus.$on('setChangeTwoMenu', (res) => { |
| | | this.menuChange(res); |
| | | }); |
| | | this.$bus.$on('showLeftMenu', (res) => { |
| | | this.$store.state.showAllLayers = true; |
| | | this.setCoverage('a1'); |
| | | // this.$bus.$emit('setAllLayers', true); |
| | | }); |
| | | }, |
| | | }; |
| | | </script> |