| | |
| | | //配置文件地址 |
| | | import config from "./config"; |
| | | // import config from "../../../../public/config/config"; |
| | | //服务加载配置文件 |
| | | import { Store } from "vuex"; |
| | | import server from "./server"; |
| | | |
| | | import store from "@/store"; |
| | | const InitMap = { |
| | | earthCtrl: null, |
| | | Viewer: null, |
| | | graticules: null, |
| | | //地图初始化 |
| | | init3DMap() { |
| | | //设置月球坐标系 |
| | | SmartEarth.Cesium.ExternalParameter.eliminate = false; |
| | | SmartEarth.Cesium.ExternalParameter.changeApproximateTerrainHeights = true; |
| | | SmartEarth.Cesium.ExternalParameter.maxTerrainHeight = 2000000; |
| | | SmartEarth.Cesium.ExternalParameter.minTerrainHeight = -2000000; |
| | | SmartEarth.Cesium.ShadowMap.MAXIMUM_DISTANCE = 20000000000; |
| | | SmartEarth.Cesium.ExternalParameter.ellipsoidCoordinates = 'MOON2000' |
| | | window.Cesium = SmartEarth.Cesium; |
| | | SmartEarth.Cesium.Ellipsoid.WGS84 = new SmartEarth.Cesium.Ellipsoid( |
| | | 1737400.0, |
| | | 1737400.0, |
| | | 1737400.0 |
| | | ); |
| | | |
| | | |
| | | //页面初始化 |
| | | this.earthCtrl = new SmartEarth.EarthCtrl("cesiumContainer", { |
| | | StaticFileBaseUrl: config.StaticFileBaseUrl, |
| | | ellipsoidCoordinates: 'MOON2000', |
| | | timeline: true, |
| | | shadowBackCul1: false |
| | | }); |
| | | // this.earthCtrl.environment.disableAllEffect(); |
| | | |
| | | this.Viewer = this.earthCtrl._Viewer; |
| | | |
| | | this.Viewer.scene.skyAtmosphere.show = false; |
| | | |
| | | this.Viewer.scene.globe.depthTestAgainstTerrain = false; |
| | | |
| | | this.earthCtrl.Viewer.scene.debugShowFramesPerSecond = true |
| | | this.earthCtrl.coreMap.scene.screenSpaceCameraController.enableCollisionDetection = true; |
| | | this.earthCtrl.Viewer.scene.globe.terrainExaggeration = 1.00001 |
| | | // this.earthCtrl.shadowMap.maximumDistance = 10000.0; |
| | | window.earthCtrl = this.earthCtrl; |
| | | |
| | | window.Viewer = this.earthCtrl._Viewer; |
| | | |
| | | Viewer.scene.skyAtmosphere.show = false; |
| | | window.Cesium = SmartEarth.Cesium; |
| | | |
| | | window.sgworld = earthCtrl; |
| | | sgworld.Creator.SimpleGraphic.edit(true, { editProp: false }); |
| | | |
| | | sgworld.Creator.SimpleGraphic.edit(true, { editProp: true }); |
| | | |
| | | Viewer.imageryLayers.removeAll(); |
| | | // 最小缩放高度(米) |
| | | // Viewer.scene.screenSpaceCameraController.minimumZoomDistance =10000; |
| | | // 最大缩放高度(米) |
| | | // Viewer.scene.screenSpaceCameraController.maximumZoomDistance = 5000000; |
| | | |
| | | //======================= |
| | | //阴影分析 |
| | | Viewer.scene.globe.lightingFadeOutDistance = 5.8e+7; |
| | | Viewer.scene.globe.enableLighting = false; |
| | | earthCtrl.shadows = false; |
| | | //设置球体颜色 |
| | | window.Viewer.scene.globe.baseColor = new Cesium.Color.fromCssColorString('#A9A9A9'); |
| | | //清除所有默认图层 |
| | | window.Viewer.imageryLayers.removeAll(); |
| | | window.setLayer(); |
| | | |
| | | // Viewer.scene.globe.depthTestAgainstTerrain = true; |
| | | Viewer.scene.globe.depthTestAgainstTerrain = false; // 开启深度测试 |
| | | Viewer.animation.container.style.visibility = "hidden"; |
| | | Viewer.timeline.container.style.visibility = "hidden"; |
| | | //======================= |
| | | //大气层 |
| | | Viewer.scene.globe.showGroundAtmosphere = false; |
| | | |
| | | // let colorAll = { |
| | | // point: Cesium.Color.fromCssColorString("#ff0000"), |
| | | // polyline: Cesium.Color.fromCssColorString("#ffff0050"), |
| | | // polygon: Cesium.Color.fromCssColorString("#ffff0050"), |
| | | // }; |
| | | // this.earthCtrl.Analysis.spaceDistance(colorAll, () => {}); |
| | | |
| | | var terrain = new SmartEarth.Cesium.CesiumTerrainProvider({ |
| | | url: config.moonTerrain, |
| | | tilingScheme: new SmartEarth.Cesium.GeographicTilingScheme({ |
| | | ellipsoid: SmartEarth.Cesium.Ellipsoid.MOON, |
| | | }), |
| | | }); |
| | | Viewer.terrainProvider = terrain; |
| | | Viewer.scene.globe.terrainExaggeration = 5; |
| | | server.AddWmtesLayer(config.moonWmts); |
| | | |
| | | |
| | | // server.AddTmsLayer(config.moonTms); |
| | | |
| | | |
| | | // server.AddGeoWmsLayer(); |
| | | // var param = { |
| | | // name: labelName, |
| | | // id: earthCtrl.factory.createUUID(), |
| | | // text: "文字工具", |
| | | // font: '50pt monospace', |
| | | // outlineWidth: 2, |
| | | // fillColor: SmartEarth.Cesium.Color.RED, |
| | | // lon: 47.5087, |
| | | // lat: 23.6963, |
| | | // alt: 10 |
| | | // }; |
| | | // labelEntity = earthCtrl.factory.createLabel(param); |
| | | |
| | | // server.AddTmsLayer('http://localhost:8080/abc'); |
| | | |
| | | // earthCtrl.camera.flyTo(47.5087, 23.6963, 300, 9.5, -45, 0.0, 5); |
| | | |
| | | // //添加鼠标左击事件 |
| | | // this.addMouseLeftClickEvents(); |
| | | // this.addMouseMouseMoveEvents(); |
| | | sgworld._Viewer.scene.debugShowFramesPerSecond = false; |
| | | sgworld.Navigate.Stop(); //取消飞行状态 |
| | | sgworld.Navigate.setPosition(-1093596.38, 5729026.12, 4136590.41); |
| | | this.addMouseLeftClickEvents(); |
| | | this.addMouseLeftDownEvents(); |
| | | }, |
| | | //鼠标左键点击事件添加 |
| | | addMouseLeftClickEvents() { |
| | | addMouseLeftDownEvents() { |
| | | if (window.handleLeftClick) { |
| | | window.handleLeftClick.removeInputAction( |
| | | Cesium.ScreenSpaceEventType.LEFT_CLICK |
| | | ); //移除事件 |
| | | window.handleLeftClick = null; |
| | | } |
| | | const pickGlobeSlope = new SmartEarth.Cesium.PickGlobeSlope(earthCtrl.Viewer) |
| | | window.handleLeftClick = new Cesium.ScreenSpaceEventHandler( |
| | | window.Viewer.scene.canvas |
| | | ); |
| | | var that = this; |
| | | window.handleLeftClick.setInputAction(function (event) { |
| | | let cartesian = window.Viewer.camera.pickEllipsoid(event.position); |
| | | if (cartesian) { |
| | | let cartographic = Cesium.Cartographic.fromCartesian(cartesian); |
| | | let lng = Cesium.Math.toDegrees(cartographic.longitude); // 经度 |
| | | let lat = Cesium.Math.toDegrees(cartographic.latitude); // 纬度 |
| | | let alt = cartographic.height; // 高度,椭球面height永远等于0 |
| | | let coordinate = { |
| | | longitude: Number(lng.toFixed(6)), |
| | | latitude: Number(lat.toFixed(6)), |
| | | altitude: Number(alt.toFixed(2)), |
| | | }; |
| | | const angle = pickGlobeSlope.pickSlope(event.position) |
| | | if (store.state.slopeQueyFlag) { |
| | | if (!store.state.showSlopeQuey) { |
| | | store.state.showSlopeQuey = true; |
| | | } |
| | | store.state.slopeQueyValue = angle.toFixed(6); |
| | | |
| | | } |
| | | |
| | | }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | }, |
| | | |
| | | //鼠标左键点击事件添加 |
| | | addMouseLeftClickEvents() { |
| | | if (window.handleLeftDown) { |
| | | window.handleLeftDown.removeInputAction( |
| | | Cesium.ScreenSpaceEventType.LEFT_DOWN |
| | | ); //移除事件 |
| | | window.handleLeftDown = null; |
| | | } |
| | | window.handleLeftDown = new Cesium.ScreenSpaceEventHandler( |
| | | window.Viewer.scene.canvas |
| | | ); |
| | | var that = this; |
| | | window.handleLeftDown.setInputAction(function (event) { |
| | | let cartesian = window.Viewer.scene.pick(event.position); |
| | | if (Cesium.defined(cartesian)) { |
| | | |
| | | if (cartesian.id.shpType && cartesian.id.shpType == 'temporaryLayer') { |
| | | |
| | | that.setEditTemporaryLayer(cartesian.id._id) |
| | | } |
| | | |
| | | } |
| | | }, Cesium.ScreenSpaceEventType.LEFT_DOWN); |
| | | }, |
| | | setEditTemporaryLayer(res) { |
| | | // store.state.editTemporaryId = res; |
| | | // console.log(store.state.editTemporaryId) |
| | | |
| | | if (store.state.editTemporaryId && store.state.editTemporaryId == res) { |
| | | |
| | | store.state.setEditTemporaryShow = true; |
| | | } |
| | | }, |
| | | addMouseMouseMoveEvents() { |
| | | if (window.handleMouseMove) { |
| | | window.handleMouseMove.removeInputAction( |
| | |
| | | console.log(moonPosition); |
| | | }, |
| | | }; |
| | | export default InitMap; |
| | | export default InitMap; |