From d46ebfb71da0148dcc2724024cf7b053d784f299 Mon Sep 17 00:00:00 2001 From: 少年 <1392120328@qq.com> Date: 星期二, 05 三月 2024 18:35:10 +0800 Subject: [PATCH] youhua --- src/components/sideMenu/layerMenu/layerPanel2.vue | 185 +++++++++++++++++++++++----------------------- 1 files changed, 93 insertions(+), 92 deletions(-) diff --git a/src/components/sideMenu/layerMenu/layerPanel2.vue b/src/components/sideMenu/layerMenu/layerPanel2.vue index c5cca81..266415e 100644 --- a/src/components/sideMenu/layerMenu/layerPanel2.vue +++ b/src/components/sideMenu/layerMenu/layerPanel2.vue @@ -109,12 +109,15 @@ import store from "@/utils/store2.js"; import ZTTitem from "@/utils/ztt2.js"; import { layers } from "../../../../static/json/layer.js"; - -// import Tile from "ol/layer/Tile"; -// import XYZ from "ol/source/XYZ"; -// import { get as getProjection, getTransform } from "ol/proj"; -// import { createXYZ } from "ol/tilegrid"; - +import { + addImageLayer, + addAnnotationLayer, + addHxLayer, + addYzLayer, + loadBaseMap, + loadGeoMap, + clearAll, +} from "@/utils/tool"; export default { name: "LayerPanel", data() { @@ -205,19 +208,19 @@ }, mounted() { this.$nextTick(() => { - setTimeout(() => { - this.handleEMapClick( - { - id: "yxdt", - name: "褰卞儚鍦板浘", - active: true, - type: "er", - src: "/static/img/yxdt.cf4698e.png", - }, - 1 - ); - loadEnterprise(); - }, 2000); + // setTimeout(() => { + // this.handleEMapClick( + // { + // id: "yxdt", + // name: "褰卞儚鍦板浘", + // active: true, + // type: "er", + // src: "/static/img/yxdt.cf4698e.png", + // }, + // 1 + // ); + // loadEnterprise(); + // }, 2000); }); }, methods: { @@ -253,36 +256,24 @@ }, // 浜岀淮搴曞浘閫夋嫨 handleEMapClick(result, index) { - // 璁剧疆鐩告満 - if (result.name == "浜岀淮鍦板浘") { - window.map.getLayerByName("浜岀淮鍦板浘").setVisible(true); - window.map.getLayerByName("褰卞儚鍦板浘").setVisible(false); - } else if (result.name == "褰卞儚鍦板浘") { - window.map.getLayerByName("褰卞儚鍦板浘").setVisible(true); - window.map.getLayerByName("浜岀淮鍦板浘").setVisible(false); - } - // 鍒囨崲鍥惧眰 - const val = layers.filter((res) => { - if (res.name == result.name) { - return res; - } - }); - const children = val[0].children; - if (this.curEMapModelIndex == index) { - // 鍐嶆鐐瑰嚮閫変腑鐨刬tem鏃跺彇娑堥�夋嫨 - // clearLayerByTypeId(result.id); - // this.curEMapModelIndex = -1; - } else { - this.curSMapModelIndex = -1; - this.curEMapModelIndex = index; - clearLayerByTypeIdArr(["ewdt", "yxdt"]); - clearLayerByTypeIdArr(["3Dcs", "swmx"]); - _GLOBAL.layers[result.id] = []; - children.forEach((item) => { - let itemLayer = loadLayer(item); - _GLOBAL.layers[result.id].push(itemLayer); - // console.log(_GLOBAL.layers[result.id]); - }); + if (this.curEMapModelIndex == index) return; + this.curEMapModelIndex = index; + clearAll(); + switch (result.name) { + case "浜岀淮鍦板浘": + loadGeoMap(); + loadBaseMap(); + addAnnotationLayer(); + addHxLayer(); + addYzLayer(); + window.mapapi.getView().setZoom(14); + break; + case "褰卞儚鍦板浘": + addImageLayer(); + addAnnotationLayer(); + addHxLayer(); + addYzLayer(); + break; } }, // 涓夌淮妯″瀷閫夋嫨 @@ -384,7 +375,7 @@ }, // 绗簩琛� 涓撻鍥� 鐐瑰嚮 handleZTlick(result, index) { - console.log(result, index); + // console.log(result, index); const val = layers.filter((res) => { if (res.name == result.name) { return res; @@ -405,73 +396,80 @@ if (this.curFuncIndex == index) { store.setTdglFlag(false); store.setPoplayerListAction({}); - divPoint3 && divPoint3.deleteObject(); store.setPoplayerShowAction(false); + this.curFuncIndex = -1; + // window.clusterLayer && window.clusterLayer.clear(); if (window.tdglLine) { - window.map.removeLayer(window.tdglLine); + window.mapapi.removeLayer(window.tdglLine); window.tdglLine = null; } - this.curFuncIndex = -1; - window.clusterLayer && window.clusterLayer.clear(); - if (window.tdglLayer) { + if (window.tdgllayer) { store.setSliderShow(false); - window.map.removeLayer(window.tdglLayer); + window.mapapi.removeLayer(window.tdgllayer); + window.tdgllayer = null; } } else { + this.curFuncIndex = index; // 闅愯棌搴曢儴鍥惧眰闈㈢増 store.setLayerPanelShow(false); // 闅愯棌鍙充笂瑙掕彍鍗曢潰鏉� store.setMenuListShow(false); // 闅愯棌搴曢儴婕父闈㈡澘 store.setRoamPanelShow(false); - this.curFuncIndex = index; switch (index) { case 0: - if (window.tdgllayer) { - window.map.removeLayer(window.tdgllayer); - store.setSliderShow(false); - window.tdgllayer = null; - window.map.removeLayer(window.tdglLine); - return; - } + //鏄剧ず婊戝姩鏉� store.setSliderShow(true); - + store.setTdglFlag(true); var url = layers[8].children[0].urls; - //"https://skyzt.bda.gov.cn/gisserver/tmsserver/chengshiguihua_dikuaibianhao_tms/"; - - window.map.removeLayer(window.tdgllayer); + //鍔犺浇鍦板潡妯″瀷 window.tdgllayer = new ol.layer.Tile({ - source: new ol.source.XYZ({ - projection: "EPSG:4326", - tileGrid: ol.tilegrid.createXYZ({ - extent: [50.582, -90, 180, 70.1558], - }), - tileUrlFunction: function (tileCoord, pixelRatio, proj) { - // return url + (tileCoord[0] - 1) + '/' + tileCoord[1] + '/' + (Math.pow(2, tileCoord[0] - 1) + tileCoord[2]) + '.jpeg'; - return ( - url + - "/" + - (tileCoord[0] - 1) + - "/" + - tileCoord[1] + - "/" + - (Math.pow(2, tileCoord[0] - 1) + tileCoord[2]) + - ".jpeg" - ); + source: new ol.source.TileWMS({ + ratio: 3, + url: "https://skyzt.bda.gov.cn/gisserver/wmsserver/chengshiguihua_dikuaibianhao", + params: { + VERSION: "1.1.1", + SRS: "EPSG:4326", + FORMAT: "image/png", + TILED: true, + LAYERS: "", }, }), }); - window.map.addLayer(window.tdgllayer); - //鏄剧ず婊戝姩鏉� - store.setTdglFlag(true); + + // window.tdgllayer = new ol.layer.Tile({ + // source: new ol.source.XYZ({ + // projection: "EPSG:4326", + // format: new ol.format.MVT(), + // tileGrid: ol.tilegrid.createXYZ({ + // // extent: [-50.582, -90, 180, 70.1558], + // extent: [-180, -90, 180, 90] + // }), + // tilePixelRatio: 3, + // tileUrlFunction: function (tileCoord, pixelRatio, proj) { + // console.log(tileCoord, '鍙傛暟') + // console.log(Math.pow(2, tileCoord[0]) + tileCoord[2] - 1) + // // return url + (tileCoord[0] - 1) + '/' + tileCoord[1] + '/' + (Math.pow(2, tileCoord[0] - 1) + tileCoord[2]) + '.jpeg'; + // return ( + // url + + // (tileCoord[0]) + + // "/" + + // tileCoord[1] + + // "/" + + // (Math.pow(2, tileCoord[0]) + tileCoord[2] - 1) + + // ".jpeg" + // ); + + // }, + // }), + // }); + + window.mapapi.addLayer(window.tdgllayer); break; case 1: this.curFuncIndex = -1; store.setTdglFlag(false); - if (window.tdglLayer) { - store.setSliderShow(false); - window.map.removeLayer(window.tdgllayer); - } + store.setSliderShow(false); store.setHistoryShow(true); break; } @@ -541,6 +539,7 @@ background: white; z-index: 1000; padding-left: 0.25rem; + border-radius: 15px 15px 0px 0px; } .title { @@ -552,9 +551,11 @@ line-height: 25px; margin: 10px 0px 10px 0; } + .title2 { height: 15px; } + .container { display: flex; align-items: center; -- Gitblit v1.9.3