From 4a5af28ba9fc254b81aae7345ae936cbaf0716be Mon Sep 17 00:00:00 2001
From: 少年 <1392120328@qq.com>
Date: 星期一, 04 三月 2024 15:33:56 +0800
Subject: [PATCH] youhua

---
 src/components/viewer2.vue |   75 +++++++++++++++++--------------------
 1 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/src/components/viewer2.vue b/src/components/viewer2.vue
index 534a607..dbd4d81 100644
--- a/src/components/viewer2.vue
+++ b/src/components/viewer2.vue
@@ -34,7 +34,7 @@
     <!-- 浣嶇疆闈㈡澘 -->
     <my-collection-panel></my-collection-panel>
     <!-- 鎸囧寳閽堥潰鏉� -->
-    <!-- <my-direction-panel></my-direction-panel> -->
+    <my-direction-panel></my-direction-panel>
     <!-- 鏂板鏀惰棌闈㈡澘 -->
     <my-add-collection-panel></my-add-collection-panel>
     <!-- 绐ㄤ簳銆佹憚鍍忓ご缁熻闈㈡澘 -->
@@ -57,7 +57,7 @@
 </template>
 <script>
 import store from "@/utils/store2.js";
-import { setClick,leftClick } from '@/utils/map2.js'
+import { setClick, leftClick } from "@/utils/map2.js";
 import _GLOBAL from "@/assets/GLOBAL2";
 // import { leftClick, loadLayer } from "@/utils/map.js";
 import leftBottom from "@/components/leftMenu/bottom2.vue";
@@ -81,7 +81,14 @@
 import mainPoplayer from "./poplayer/poplayer2.vue";
 import sliderAlpha from "./sideMenu/sliderAlpha/main2.vue";
 import Axios from "axios";
-
+import {
+  addImageLayer,
+  addAnnotationLayer,
+  addHxLayer,
+  addYzLayer,
+  loadBaseMap,
+  getCurrentPosition,
+} from "@/utils/tool";
 // import Map from "ol/Map.js";
 // import TileLayer from "ol/layer/Tile.js";
 // import View from "ol/View.js";
@@ -114,7 +121,7 @@
     "my-history": history,
     "my-land-admin-info": landAdminInfo,
     "my-slider": sliderAlpha,
-    "my-poplayer":mainPoplayer
+    "my-poplayer": mainPoplayer,
   },
   data() {
     return {
@@ -137,11 +144,9 @@
       state: store.history,
     };
   },
-  created() { },
+  created() {},
   mounted() {
     this.$nextTick(function () {
-      console.log("openlayer init");
-
       ol.Map.prototype.getLayerByName = function (name) {
         var layer;
         this.getLayers().array_.forEach(function (lyr) {
@@ -164,11 +169,15 @@
 
       let projection = ol.proj.get(_proj);
       let projectionExtent = projection.getExtent();
-      let origin = projectionExtent ? ol.extent.getTopLeft(projectionExtent) : [-180, 90];
+      let origin = projectionExtent
+        ? ol.extent.getTopLeft(projectionExtent)
+        : [-180, 90];
       let fromLonLat = ol.proj.getTransform("EPSG:4326", projection);
       let width = projectionExtent
         ? ol.extent.getWidth(projectionExtent)
-        : ol.extent.getWidth(ol.extent.applyTransform([-180.0, -90.0, 180.0, 90.0], fromLonLat));
+        : ol.extent.getWidth(
+            ol.extent.applyTransform([-180.0, -90.0, 180.0, 90.0], fromLonLat)
+          );
 
       let resolutions = [];
       let matrixIds = [];
@@ -235,13 +244,13 @@
         id: "cva_c",
         source: wmtsSource2,
       });
-      wmtsLayer2.setVisible(false);
-      ////鍗槦褰卞儚
-      layers.push(wmtsLayer);
+      // wmtsLayer2.setVisible(false);
       ////浜岀淮鍦板浘
-      layers.push(wmtsLayer2);
+      // layers.push(wmtsLayer2);
+      ////鍗槦褰卞儚
+      // layers.push(wmtsLayer);
       ////璺綉
-      layers.push(wmtsLayer1);
+      // layers.push(wmtsLayer1);
 
       const map = new ol.Map({
         layers: layers,
@@ -250,36 +259,21 @@
           center: [116.505348, 39.795592],
           projection: "EPSG:4326",
           zoom: 12,
+          minZoom: 9.5,
         }),
+        // events: ["singleclick", "pointermove"],
       });
 
       window.mapapi = map;
-      setClick(true)
-      // leftClick()
-      // var url =
-      //   "https://skyzt.bda.gov.cn/gisserver/tmsserver/chengshiguihua_dikuaibianhao_tms/";
 
-      // var tmslayer = new ol.layer.Tile({
-      //   source: new ol.source.XYZ({
-      //     projection: projection,
-      //     tileGrid: ol.tilegrid.createXYZ({
-      //       extent: [50.731, -90, 180, 70.0478],
-      //     }),
-      //     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"
-      //       );
-      //     },
-      //   }),
-      // });
-      // window.mapapi.addLayer(tmslayer);
+      addImageLayer();
+      addAnnotationLayer();
+      addHxLayer();
+      addYzLayer();
+
+      setClick(true);
+      getCurrentPosition();
+      // leftClick()
 
       window.layerOpen = function (name, options) {
         layuiLayer.close(SmartEarthPopupData.layerProp);
@@ -397,7 +391,7 @@
       console.log(window.gisBaseUrl);
       Axios.get(
         window.gisBaseUrl +
-        "/gisserver/wfsserver/qiyelianqiye?version=1.3.0&request=GetFeature&format=json&typename=浼佷笟閾句紒涓�"
+          "/gisserver/wfsserver/qiyelianqiye?version=1.3.0&request=GetFeature&format=json&typename=浼佷笟閾句紒涓�"
       ).then((res) => {
         console.log(res);
       });
@@ -447,5 +441,4 @@
 .colseBtn img {
   width: 30px;
 }
-
 </style>

--
Gitblit v1.9.3