| | |
| | | import store from "@/store"; |
| | | import configTool from "@/assets/js/tool/configTool"; |
| | | const mapClick = { |
| | | Init() { |
| | | this.addLeftClick(); |
| | | this.addRightClick(); |
| | | addEventListener("mouseup", (event) => { |
| | | store.state.rightMeuFlag = false; |
| | | }); |
| | | }, |
| | | addLeftClick() { |
| | | var that = this; |
| | | let handler = new Cesium.ScreenSpaceEventHandler(Viewer.scene.canvas); |
| | | handler.setInputAction(function (event) { |
| | | console.log("您的鼠标左击了一下"); |
| | | store.state.rightMeuFlag = false; |
| | | let pick = Viewer.scene.pick(event.position); |
| | | if (Cesium.defined(pick)) { |
| | | if (pick.id && pick.id._properties) { |
| | |
| | | }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| | | }, |
| | | addRightClick() { |
| | | var that = this; |
| | | let handler = new Cesium.ScreenSpaceEventHandler(Viewer.scene.canvas); |
| | | handler.setInputAction(function (event) { |
| | | console.log("您的鼠标右击了一下"); |
| | | // 开启右侧菜单 |
| | | that.showRightMenu(event); |
| | | // 右击获取经纬度 |
| | | that.setRIghtPosition(event); |
| | | }, Cesium.ScreenSpaceEventType.RIGHT_CLICK); |
| | | }, |
| | | showProperties(res) { |
| | | store.state.showProperties = res; |
| | | }, |
| | | setRIghtPosition(res) { |
| | | var coodinate = configTool.getViewerPosition(res); |
| | | store.state.rightCoodinate = coodinate; |
| | | }, |
| | | showRightMenu(res) { |
| | | document.getElementsByClassName("rightMenuBox")[0].style.left = |
| | | res.position.x + "px"; |
| | | document.getElementsByClassName("rightMenuBox")[0].style.top = |
| | | res.position.y + "px"; |
| | | store.state.rightMeuFlag = true; |
| | | }, |
| | | }; |
| | | export default mapClick; |