| | |
| | | <div>{{ $t(item.label) }}</div> |
| | | </div> |
| | | <mapinfo ref="mapinfo" /> |
| | | <maplayer ref="maplayer" /> |
| | | <input type="file" accept=".kml" class="file" style="display: none" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { transform } from 'ol/proj'; |
| | | import mapinfo from '../Tools/mapinfo.vue'; |
| | | import maplayer from '../Tools/maplayer.vue'; |
| | | |
| | | export default { |
| | | components: { mapinfo }, |
| | | components: { mapinfo, maplayer }, |
| | | data() { |
| | | return { |
| | | showTwoMenuFlag: false, |
| | |
| | | isNaviget: false, |
| | | isolineFlag: false, |
| | | isslopeFlag: false, |
| | | isContrastFlag: false, |
| | | }; |
| | | }, |
| | | methods: { |
| | |
| | | this.$store.state.mapPopBoolean = false; |
| | | this.$store.state.mapPopBoxFlag = null; |
| | | var val = res.id[0]; |
| | | if (window.model != null) { |
| | | window.model.deleteObject(); |
| | | window.model = null; |
| | | } |
| | | switch (val) { |
| | | case 'a': //图层管理 |
| | | this.setCoverage(res.id); |
| | |
| | | this.setMeasurement(res.id); |
| | | break; |
| | | case 'h': |
| | | sgworld.Creator.SimpleGraphic.edit(true, { editProp: true }); |
| | | this.setPlot(res.id); |
| | | break; |
| | | } |
| | |
| | | function (entity) {} |
| | | ); |
| | | break; |
| | | case 'h5': |
| | | this.handleOpenClick(); |
| | | break; |
| | | case 'h6': |
| | | this.handleSaveClick(); |
| | | break; |
| | | case 'h7': |
| | | sgworld.Creator.SimpleGraphic.clear(); |
| | | |
| | | break; |
| | | } |
| | | }, |
| | | handleSaveClick() { |
| | | let funDownload = function (content, filename) { |
| | | let eleLink = document.createElement('a'); |
| | | eleLink.download = filename; |
| | | eleLink.style.display = 'none'; |
| | | // 字符内容转变成blob地址 |
| | | let blob = new Blob([content]); |
| | | eleLink.href = URL.createObjectURL(blob); |
| | | // 触发点击 |
| | | document.body.appendChild(eleLink); |
| | | eleLink.click(); |
| | | // 然后移除 |
| | | document.body.removeChild(eleLink); |
| | | }; |
| | | let entities = new Cesium.EntityCollection(); |
| | | let dataSources = sgworld.Viewer.dataSources; |
| | | for (let i = 0, j = dataSources.length; i < j; i++) { |
| | | for (let v of dataSources.get(i).entities.values) { |
| | | entities.add(v); |
| | | } |
| | | } |
| | | for (let v of sgworld.Viewer.entities.values) { |
| | | entities.add(v); |
| | | } |
| | | |
| | | if (entities.values.length) { |
| | | console.log(sgworld.Viewer.entities); |
| | | |
| | | let promise = Cesium.exportKml({ entities: sgworld.Viewer.entities }); |
| | | console.log(entities); |
| | | // let promise = Cesium.exportKml({ entities: entities }); |
| | | promise.then(function (e) { |
| | | funDownload(e.kml, new Date().getTime() + '.kml'); |
| | | }); |
| | | } else { |
| | | alert('当前场景没有entities实体'); |
| | | } |
| | | }, |
| | | handleOpenClick() { |
| | | // let that = this; |
| | | let fileInput = document.querySelector('.file'); |
| | | fileInput.onchange = function (evt) { |
| | | let files = evt.target.files; |
| | | if (files.length > 0) { |
| | | let file = evt.target.files[0]; |
| | | 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; |
| | | }); |
| | | }; |
| | | } |
| | | // fileInput.value = null; |
| | | }; |
| | | fileInput.click(); |
| | | }, |
| | | setMeasurement(res) { |
| | | switch (res) { |
| | |
| | | this.addterrainSectionAnalysis(); |
| | | } |
| | | break; |
| | | |
| | | case 'd5': |
| | | if (window.AnalysisFlood) { |
| | | this.clear(res.id); |
| | | this.clear(res); |
| | | } else { |
| | | this.addAnalysisFlood(); |
| | | } |
| | |
| | | } |
| | | ); |
| | | break; |
| | | case 'd7': |
| | | var that = this; |
| | | window.model = sgworld.Creator.create3DTilesets( |
| | | '', |
| | | modelUrl, |
| | | {}, |
| | | {}, |
| | | '0', |
| | | true, |
| | | (data) => { |
| | | sgworld.Navigate.flyToObj(data); |
| | | that.setclippingModel(); |
| | | } |
| | | ); |
| | | break; |
| | | case 'd8': |
| | | if (this.isContrastFlag == false) { |
| | | this.isContrastFlag = true; |
| | | sgworld.Analysis.createCurtainContrast(2, 1); |
| | | } else { |
| | | this.isContrastFlag = false; |
| | | sgworld.Analysis.clearCurtainContrast(); |
| | | } |
| | | break; |
| | | case 'd10': |
| | | if (window.TerrainFlattening) { |
| | | window.TerrainFlattening.remove(); |
| | | window.TerrainFlattening = null; |
| | | } else { |
| | | sgworld.Creator.createSimpleGraphic( |
| | | 'polygon', |
| | | { |
| | | clampToGround: true, |
| | | }, |
| | | function (entity) { |
| | | var positions = entity.polygon.hierarchy.getValue().positions; |
| | | sgworld.Creator.SimpleGraphic.remove(entity.id); |
| | | window.TerrainFlattening = |
| | | sgworld.Creator.createTerrainModifier( |
| | | '地形压平', |
| | | positions, |
| | | 10, |
| | | {} |
| | | ); |
| | | } |
| | | ); |
| | | } |
| | | break; |
| | | case 'd11': |
| | | if (window.Excavation) { |
| | | window.Excavation.clear(); |
| | | window.Excavation = null; |
| | | } else { |
| | | window.Excavation = sgworld.Analysis.TerrainExcavation( |
| | | 10, |
| | | {}, |
| | | function () {} |
| | | ); |
| | | } |
| | | break; |
| | | } |
| | | }, |
| | | setclippingModel() { |
| | | if (window.model) { |
| | | setTimeout(() => { |
| | | window.model.clippingModel({ |
| | | direction: 'z', |
| | | }); |
| | | }, 1000); |
| | | // window.model.clippingModel({ |
| | | // direction: 'z', |
| | | // }); |
| | | } |
| | | }, |
| | | clear(res) { |
| | |
| | | } |
| | | break; |
| | | case 'd5': |
| | | window.AnalysisFlood && window.AnalysisFlood.endWater(); |
| | | window.AnalysisFlood.endWater(); |
| | | window.AnalysisFlood = undefined; |
| | | |
| | | break; |
| | | } |
| | | }, |
| | |
| | | skin: 'other-class', |
| | | content: '/SmartEarthSDK/Workers/analysis/AnalysisDXPM.html', |
| | | end: () => { |
| | | this.dxpmIndex && this.clear('4'); |
| | | this.dxpmIndex && this.clear('d4'); |
| | | }, |
| | | }); |
| | | } else { |
| | |
| | | window.sgworld.Analysis.setPointFly(); |
| | | break; |
| | | case 'c2': |
| | | var url = window.location.href; |
| | | var testurl = ''; |
| | | if (url.indexOf('web') != -1) { |
| | | testurl = '/web'; |
| | | } |
| | | window.sgworld.Command.execute(2, 3, '', (data) => { |
| | | data.showPoint = false; |
| | | data.showLine = true; |
| | |
| | | area: ['352px', '690px'], |
| | | offset: 'r', |
| | | skin: 'other-class', |
| | | content: '/SmartEarthSDK/Workers/path/Path.html', |
| | | content: testurl + '/SmartEarthSDK/Workers/path/Path.html', |
| | | end: function () { |
| | | PathAnimationData.fly && PathAnimationData.fly.exit(); |
| | | }, |
| | |
| | | break; |
| | | } |
| | | }, |
| | | setCoverage(res) { |
| | | switch (res) { |
| | | case 'a1': |
| | | this.$refs && this.$refs.maplayer && this.$refs.maplayer.open(); |
| | | break; |
| | | } |
| | | }, |
| | | menuChange(res) { |
| | | this.setListTwoMenu = this.setListTwoMenuAll[res]; |
| | | }, |