From 8b8f88d7d8d713a1355d9849f467e3a2dc0c22fe Mon Sep 17 00:00:00 2001 From: Surpriseplus <845948745@qq.com> Date: 星期二, 05 九月 2023 14:50:26 +0800 Subject: [PATCH] 配置文件修改 --- src/assets/js/Map/index.js | 2 src/views/query/SpatialQuery.vue | 2 public/config/config1.js | 5 + src/views/layer/attributeList.vue | 2 src/views/search/search.vue | 2 src/assets/js/Map/olMap.js | 54 +++++++++-------- src/assets/js/Map/rightServer.js | 2 src/store/index.ts | 3 + src/utils/request.js | 2 /dev/null | 26 -------- src/assets/js/Map/server.js | 2 src/views/login.vue | 2 public/config/config.js | 27 ++++++++- src/views/Map/olMap.vue | 21 ++++++ src/assets/js/Map/menuTool.js | 2 15 files changed, 89 insertions(+), 65 deletions(-) diff --git a/public/config/config.js b/public/config/config.js index f6a3fee..b4f5ec7 100644 --- a/public/config/config.js +++ b/public/config/config.js @@ -1,5 +1,26 @@ -const BASE_URL = "http://192.168.20.83:8088/MoonServer/"; //鍚庣鎺ュ彛鍦板潃 -// const BASE_URL = "http://192.168.20.106:9000/MoonServer/"; //鍚庣鎺ュ彛鍦板潃 +//鏄惁涓虹敓浜х幆澧� +var isWeb = location.hostname.indexOf("103.85.165.") > -1; +//鏄惁涓虹敓浜х幆澧� +const webUrl = location.href.indexOf("/web") > -1 ? "/web" : ""; +var webHost = isWeb ? "103.85.165.99" + ":28888" : '192.168.20.83' + ":8888"; +//閰嶇疆鏂囦欢鍦板潃 +const config = { + mapMoon: webUrl + "/mapscreen/index.html", + //妞悆浣撳垵濮嬪寲鍔犺浇鍥剧墖 + imgUrl: "Workers/image/earth.jpg", + //license璁稿彲 + licenseServer: "http://183.162.245.49:18080", + //SDK璁稿彲 + StaticFileBaseUrl: webUrl + "/CIMSDK/", -var isWeb = location.hostname.indexOf("103.85.165.") > -1; \ No newline at end of file + proxy: "http://" + webHost + "/MoonServer", + + BASE_URL: "http://" + webHost + "/MoonServer", + conditions: [ + ["=", "<>", "like"], + [">=", ">", " =", "<=", "<", "<>"], + [">=", ">", " =", "<=", "<", "<>"], + ], +}; +export default config; diff --git a/public/config/config1.js b/public/config/config1.js new file mode 100644 index 0000000..f6a3fee --- /dev/null +++ b/public/config/config1.js @@ -0,0 +1,5 @@ +const BASE_URL = "http://192.168.20.83:8088/MoonServer/"; //鍚庣鎺ュ彛鍦板潃 +// const BASE_URL = "http://192.168.20.106:9000/MoonServer/"; //鍚庣鎺ュ彛鍦板潃 + + +var isWeb = location.hostname.indexOf("103.85.165.") > -1; \ No newline at end of file diff --git a/src/assets/js/Map/config.js b/src/assets/js/Map/config.js deleted file mode 100644 index b4f5ec7..0000000 --- a/src/assets/js/Map/config.js +++ /dev/null @@ -1,26 +0,0 @@ -//鏄惁涓虹敓浜х幆澧� -var isWeb = location.hostname.indexOf("103.85.165.") > -1; -//鏄惁涓虹敓浜х幆澧� -const webUrl = location.href.indexOf("/web") > -1 ? "/web" : ""; - -var webHost = isWeb ? "103.85.165.99" + ":28888" : '192.168.20.83' + ":8888"; -//閰嶇疆鏂囦欢鍦板潃 -const config = { - mapMoon: webUrl + "/mapscreen/index.html", - //妞悆浣撳垵濮嬪寲鍔犺浇鍥剧墖 - imgUrl: "Workers/image/earth.jpg", - //license璁稿彲 - licenseServer: "http://183.162.245.49:18080", - //SDK璁稿彲 - StaticFileBaseUrl: webUrl + "/CIMSDK/", - - proxy: "http://" + webHost + "/MoonServer", - - BASE_URL: "http://" + webHost + "/MoonServer", - conditions: [ - ["=", "<>", "like"], - [">=", ">", " =", "<=", "<", "<>"], - [">=", ">", " =", "<=", "<", "<>"], - ], -}; -export default config; diff --git a/src/assets/js/Map/index.js b/src/assets/js/Map/index.js index 02cef4c..b4ae8df 100644 --- a/src/assets/js/Map/index.js +++ b/src/assets/js/Map/index.js @@ -1,5 +1,5 @@ //閰嶇疆鏂囦欢鍦板潃 -import config from "./config"; +import config from "../../../../public/config/config"; //鏈嶅姟鍔犺浇閰嶇疆鏂囦欢 import server from "./server"; diff --git a/src/assets/js/Map/menuTool.js b/src/assets/js/Map/menuTool.js index 66dfe8e..7524871 100644 --- a/src/assets/js/Map/menuTool.js +++ b/src/assets/js/Map/menuTool.js @@ -1,7 +1,7 @@ import * as turf from "@turf/turf"; import WKT from "terraformer-wkt-parser"; import rightServer from "./rightServer"; -import config from "./config"; +import config from "../../../../public/config/config"; import CryptoJS from "crypto-js"; // import { Store } from "vuex"; import store from "@/store"; diff --git a/src/assets/js/Map/olMap.js b/src/assets/js/Map/olMap.js index 5b90955..1c0fdbb 100644 --- a/src/assets/js/Map/olMap.js +++ b/src/assets/js/Map/olMap.js @@ -1,6 +1,6 @@ import { getToken } from "@/utils/auth"; //閰嶇疆鏂囦欢鍦板潃 -import config from "./config"; +import config from "../../../../public/config/config"; import { Map, View } from "ol"; //鍦板浘,瑙嗗浘 import OSM from "ol/source/OSM"; //鍙互鐞嗚В涓烘暟鎹簮,灏辨槸涓�寮犲浘鐗� import TileLayer from "ol/layer/Tile"; //鍙互鐞嗚В涓哄浘灞� @@ -10,14 +10,16 @@ import WMTSTileGrid from "ol/tilegrid/WMTS.js"; import { get as getProjection, Projection } from "ol/proj.js"; import { register } from "ol/proj/proj4"; - +import MousePosition from "ol/control/MousePosition.js"; import { getTopLeft, getWidth } from "ol/extent.js"; +import { format } from "ol/coordinate"; +import store from "@/store"; const olMap = { map: null, Layer: null, projectionObj: { - code: "ESRI:103881", - extent: [-180, -90, 180, 90], + code: null, + extent: null, }, initMap() { //google鍦板浘 @@ -31,10 +33,21 @@ // "+proj=laea +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +R=1737400 +units=m +no_defs +type=crs" // ); // register(proj4); + let mousePositionControl = new MousePosition({ + coordinateFormat: (coordinate) => { + store.state.olLon = coordinate[0].toFixed(6) + store.state.olLat = coordinate[1].toFixed(6); + if (this.map) { + store.state.olZoom = parseInt(this.map.getView().getZoom()) + } + }, + projection: this.projectionObj.code, + target: 'mouse', + }); const projection = new Projection({ // code: this.projectionObj.code, - code: "ESRI:103881", - extent: [-180, -90, 180, 90], + code: this.projectionObj.code, + extent: this.projectionObj.extent, // extent: this.projectionObj.extent, }); this.map = new Map({ @@ -42,15 +55,15 @@ layers: [], //AMapLayer, baiduMapLayer view: new View({ projection: projection, - center: [180, 90], + center: [0, 0], zoom: 4, }), + controls: [mousePositionControl] }); }, addTreeData(treeNode, obj) { // this.delLayerAll(); this.projectionObj = obj; - console.log(this.projectionObj); //鍒ゆ柇鏄惁涓轰唬鐞� if (treeNode.proxy) { this.addProxyAddress(treeNode); //鏈変唬鐞� @@ -164,8 +177,13 @@ code: this.projectionObj.code, // extent: this.projectionObj.extent, // code: "ESRI:103879", - extent: [-180, -90, 180, 90], + extent: this.projectionObj.extent, }); + + if (this.map) { + this.map.values_.view.projection_ = projection + } + // var projection = getProjection("ESRI:103880"); var projectionExtent = projection.getExtent(); @@ -196,27 +214,11 @@ }); if (this.map) { this.map.addLayer(this.Layer); - var that = this; - window.olMap = this.map; - window.layer = this.Layer - setTimeout(() => { - that.getLayersExtent(); - }, 1000) - // this.Layer.getSource().on('addfeature', function () { - // this.map.getView().fit(this.Layer.getSource().getExtent()); - // }); - + this.map.getView().fit(this.projectionObj.extent); } }, - getLayersExtent() { - // 缂╂斁鑷冲浘灞傝寖鍥� - this.map.getView().fit(this.Layer.renderer_.renderedExtent_); - - - - } }; export default olMap; diff --git a/src/assets/js/Map/rightServer.js b/src/assets/js/Map/rightServer.js index d5e9a48..95fc031 100644 --- a/src/assets/js/Map/rightServer.js +++ b/src/assets/js/Map/rightServer.js @@ -1,6 +1,6 @@ import { getToken } from "@/utils/auth"; //閰嶇疆鏂囦欢鍦板潃 -import config from "./config"; +import config from "../../../../public/config/config"; const rightServer = { layerList: [], diff --git a/src/assets/js/Map/server.js b/src/assets/js/Map/server.js index f02e777..97fc2ac 100644 --- a/src/assets/js/Map/server.js +++ b/src/assets/js/Map/server.js @@ -1,6 +1,6 @@ import { getToken } from "@/utils/auth"; //閰嶇疆鏂囦欢鍦板潃 -import config from "./config"; +import config from "../../../../public/config/config"; import store from "@/store"; const server = { layerList: [], diff --git a/src/store/index.ts b/src/store/index.ts index bc1b009..6734c3c 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -32,6 +32,9 @@ spatialTitle: null, setExportList: false, setLayerManager: false, + olLon: "0.00", + olLat: "0.00", + olZoom: 0, }, mutations: { //鑾峰彇鐧诲綍Code diff --git a/src/utils/request.js b/src/utils/request.js index 9aadba7..af30145 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -10,7 +10,7 @@ import router from "@/router/index"; import { getToken } from "@/utils/auth"; -import config from "../assets/js/Map/config"; +import config from "../../public/config/config"; // create an axios instance const service = axios.create({ baseURL: config.BASE_URL, // api鐨刡ase_url diff --git a/src/views/Map/olMap.vue b/src/views/Map/olMap.vue index bb31dca..b2e3d72 100644 --- a/src/views/Map/olMap.vue +++ b/src/views/Map/olMap.vue @@ -2,10 +2,16 @@ <div id="mapView" class="mapView" - ></div> + > + + <div class="coordinate">缁忓害锛歿{store.state.olLon}} 绾害锛歿{store.state.olLat }} 绾у埆锛歿{store.state.olZoom }} </div> + + </div> </template> <script lang="ts" setup> +import { useStore } from "vuex"; // 寮曞叆useStore 鏂规硶 +const store = useStore(); // 璇ユ柟娉曠敤浜庤繑鍥瀞tore 瀹炰緥 import olMap from "@/assets/js/Map/olMap"; import { ref, @@ -27,5 +33,18 @@ margin: 0; padding: 0; position: absolute; + .coordinate { + bottom: 1%; + left: 1%; + padding: 10px; + background: rgba(7, 8, 14, 0.8); + z-index: 30; + box-shadow: inset 0px 2px 10px 2px rgba(38, 47, 71, 1); + position: absolute; + font-size: 16px; + font-family: Source Han Sans CN; + font-weight: 400; + color: #ffffff; + } } </style> \ No newline at end of file diff --git a/src/views/layer/attributeList.vue b/src/views/layer/attributeList.vue index 1ede907..01be3dc 100644 --- a/src/views/layer/attributeList.vue +++ b/src/views/layer/attributeList.vue @@ -161,7 +161,7 @@ nextTick, watch, } from "vue"; -import config from "@/assets/js/Map/config"; +import config from "../../../public/config/config.js"; import { User, Lock, Plus, Location } from "@element-plus/icons-vue"; import { dataQuery_selectByPage, dataQuery_selectFields } from "@/api/api"; import { ElMessage } from "element-plus"; diff --git a/src/views/login.vue b/src/views/login.vue index c0a8d36..3e84f10 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -94,7 +94,7 @@ defineProps, defineEmits, } from "vue"; -import config from "@/assets/js/Map/config"; +import config from "../../public/config/config.js"; //Router import router from "@/router"; //鍥炬爣 diff --git a/src/views/query/SpatialQuery.vue b/src/views/query/SpatialQuery.vue index efe40e0..5bd012f 100644 --- a/src/views/query/SpatialQuery.vue +++ b/src/views/query/SpatialQuery.vue @@ -268,7 +268,7 @@ nextTick, } from "vue"; import menuTool from "@/assets/js/Map/menuTool"; -import config from "@/assets/js/Map/config"; +import config from "../../../public/config/config.js"; import { User, Lock, Plus, Refresh, Location } from "@element-plus/icons-vue"; import { dataQuery_selectByPage, diff --git a/src/views/search/search.vue b/src/views/search/search.vue index dafb57a..65f47ee 100644 --- a/src/views/search/search.vue +++ b/src/views/search/search.vue @@ -112,7 +112,7 @@ ArrowRight, DArrowRight, } from "@element-plus/icons-vue"; -import config from "@/assets/js/Map/config"; +import config from "../../../public/config/config.js"; import { dataQuery_selectByPage } from "@/api/api.js"; import { ElMessage } from "element-plus"; let searchValue = ref(""); -- Gitblit v1.9.3