Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/types/components.d.ts
yangyuxuan 1 mesiac pred
rodič
commit
e26c7b9d7d

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
src/assets/json/gd.json


+ 9 - 9
src/components/Map/YztMap/index.vue

@@ -55,20 +55,20 @@ watch(
 );
 const mapList = reactive({
   satellite2: [
-    { layer: 'map', code: 'YZT1712111943104', zIndex: '-99', visible: true },
-    { layer: 'annotation', code: 'YZT1695608158269', zIndex: '-98', visible: true }
+    { layer: 'map', layerType: 'WFS', code: 'YZT1712111943104', zIndex: '-99', visible: true },
+    { layer: 'annotation', layerType: 'WMTS', code: 'YZT1695608158269', zIndex: '-98', visible: true }
   ],
   satellite3: [
-    { layer: 'map', code: 'YZT1708679726700', zIndex: '-99', visible: true },
-    { layer: 'annotation', code: 'YZT1695608158269', zIndex: '-98', visible: true }
+    { layer: 'map', layerType: 'WMTS', code: 'YZT1708679726700', zIndex: '-99', visible: true },
+    { layer: 'annotation', layerType: 'WMTS', code: 'YZT1695608158269', zIndex: '-98', visible: true }
   ],
   imageMap: [
-    { layer: 'map', code: 'YZT1640925052482', zIndex: '-99' },
-    { layer: 'annotation', code: 'YZT1695608158269', zIndex: '-98', visible: true }
+    { layer: 'map', layerType: 'WMTS', code: 'YZT1640925052482', zIndex: '-99' },
+    { layer: 'annotation', layerType: 'WMTS', code: 'YZT1695608158269', zIndex: '-98', visible: true }
   ],
   imageMap2: [
-    { layer: 'map', code: 'YZT1640925052482', zIndex: '-99', visible: true },
-    { layer: 'annotation', code: 'YZT1695608158269', zIndex: '-98', visible: true }
+    { layer: 'map', layerType: 'JSON', code: 'gd', zIndex: '-99', visible: true },
+    { layer: 'annotation', layerType: 'WMTS', code: 'YZT1695608158269', zIndex: '-98', visible: true }
   ]
 });
 // 监听地图类型变化
@@ -299,7 +299,7 @@ const filterTd = (obj, dataType) => {
     data.push(tempData);
   }
   if (data[data.length - 1].data && data[data.length - 1].data.length === 1 && data[data.length - 1].type === 'shortText') {
-    data[data.length - 1].data[1] = { label: '', value: '' };
+    data[data.length - 1].type = 'longText';
   }
   return data;
 };

+ 1 - 1
src/components/Map/index.vue

@@ -249,7 +249,7 @@ const filterTd = (obj, dataType) => {
     data.push(tempData);
   }
   if (data[data.length - 1].data && data[data.length - 1].data.length === 1 && data[data.length - 1].type === 'shortText') {
-    data[data.length - 1].data[1] = { label: '', value: '' };
+    data[data.length - 1].type = 'longText';
   }
   return data;
 };

+ 1 - 0
src/components/Map/map.scss

@@ -109,6 +109,7 @@ $vw_base: 4480;
     width: vw(12);
     height: vw(12);
     background: url('@/assets/images/inputIcon1.png') no-repeat;
+    background-size: 100% 100%;
   }
   .icon2 {
     left: unset;

+ 2 - 1
src/hooks/AMap/useAMap.ts

@@ -248,7 +248,7 @@ export function useAMap(options) {
       const data = obj[key];
       if (clickMarker) {
         const extData = clickMarker.getExtData();
-        if (data.id === extData.id) {
+        if (data.id === extData.id && data.dataType === extData.dataType) {
           hideInfoFlag = false;
           data.isHover = true;
         }
@@ -329,6 +329,7 @@ export function useAMap(options) {
         plotLayers['points2'].addOverlay(marker);
         addPoints.push(data);
         if (data.isHover) {
+          clickMarker = marker;
           options.onMarkerClick(data);
         }
       }

+ 0 - 25
src/types/components.d.ts

@@ -27,14 +27,8 @@ declare module 'vue' {
     ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
     ElBadge: typeof import('element-plus/es')['ElBadge']
     ElButton: typeof import('element-plus/es')['ElButton']
-    ElCard: typeof import('element-plus/es')['ElCard']
-    ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
-    ElCol: typeof import('element-plus/es')['ElCol']
     ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
     ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
-    ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
-    ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
-    ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
     ElDialog: typeof import('element-plus/es')['ElDialog']
     ElDivider: typeof import('element-plus/es')['ElDivider']
     ElDrawer: typeof import('element-plus/es')['ElDrawer']
@@ -42,32 +36,14 @@ declare module 'vue' {
     ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
     ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
     ElEmpty: typeof import('element-plus/es')['ElEmpty']
-    ElForm: typeof import('element-plus/es')['ElForm']
-    ElFormItem: typeof import('element-plus/es')['ElFormItem']
     ElIcon: typeof import('element-plus/es')['ElIcon']
-    ElImage: typeof import('element-plus/es')['ElImage']
-    ElInput: typeof import('element-plus/es')['ElInput']
-    ElLink: typeof import('element-plus/es')['ElLink']
     ElMenu: typeof import('element-plus/es')['ElMenu']
     ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
-    ElOption: typeof import('element-plus/es')['ElOption']
-    ElPagination: typeof import('element-plus/es')['ElPagination']
     ElPopover: typeof import('element-plus/es')['ElPopover']
-    ElRadio: typeof import('element-plus/es')['ElRadio']
-    ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
-    ElRow: typeof import('element-plus/es')['ElRow']
     ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
-    ElSelect: typeof import('element-plus/es')['ElSelect']
     ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
     ElSwitch: typeof import('element-plus/es')['ElSwitch']
-    ElTable: typeof import('element-plus/es')['ElTable']
-    ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
-    ElTag: typeof import('element-plus/es')['ElTag']
-    ElText: typeof import('element-plus/es')['ElText']
     ElTooltip: typeof import('element-plus/es')['ElTooltip']
-    ElTree: typeof import('element-plus/es')['ElTree']
-    ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
-    ElUpload: typeof import('element-plus/es')['ElUpload']
     ExcelEditor: typeof import('./../components/ExcelEditor/index.vue')['default']
     FileUpload: typeof import('./../components/FileUpload/index.vue')['default']
     FlvVideo: typeof import('./../components/FlvVideo/index.vue')['default']
@@ -79,7 +55,6 @@ declare module 'vue' {
     HikvisionPlayer: typeof import('./../components/HKVideo/hikvision-player.vue')['default']
     HKVideo: typeof import('./../components/HKVideo/index.vue')['default']
     IconSelect: typeof import('./../components/IconSelect/index.vue')['default']
-    IEpUploadFilled: typeof import('~icons/ep/upload-filled')['default']
     IFrame: typeof import('./../components/iFrame/index.vue')['default']
     ImagePreview: typeof import('./../components/ImagePreview/index.vue')['default']
     ImageUpload: typeof import('./../components/ImageUpload/index.vue')['default']

+ 99 - 44
src/utils/olMap/olMap.ts

@@ -22,12 +22,10 @@ import { defaults, ScaleLine } from 'ol/control';
 import Vector from 'ol/layer/Vector';
 import SourceVector from 'ol/source/Vector';
 import GeoJSON from 'ol/format/GeoJSON';
-import { fromLonLat } from 'ol/proj';
 import axios from 'axios';
 import { fromExtent } from 'ol/geom/Polygon';
 import { LinearRing, LineString, Polygon } from 'ol/geom';
 import { Graticule } from 'ol/layer';
-import { getPointsCenter, mergeGeoJsonPolygons } from '@/utils/gisUtils';
 import { Cluster } from 'ol/source';
 import CircleStyle from 'ol/style/Circle';
 import Overlay from 'ol/Overlay';
@@ -41,6 +39,7 @@ import { nanoid } from 'nanoid';
 import carImg from '@/assets/images/car.png';
 import { globalHeaders } from '@/utils/request';
 import { iconList } from '@/views/globalMap/data/mapData';
+import gdJson from '@/assets/json/gd.json';
 
 const tk = 'a8df87f1695d224d2679aa805c1268d9';
 const commonUrl = import.meta.env.VITE_APP_BASE_API2 + 'api/oneShare/proxyHandler/gd/';
@@ -96,7 +95,6 @@ export class olMap {
   private traceFeature;
   // 自定义绘制结束调用方法
   private drawEndMethod;
-  private selectedFeature;
   private drawing;
   private path;
   private anyLine;
@@ -161,10 +159,9 @@ export class olMap {
       const feature = event.selected[0]; // 获取被选中的要素集合
       const extData = feature.get('extData');
       if (!!feature) {
-        this.clickMarker = feature;
-        if (this.selectedFeature) {
-          const selectData = this.selectedFeature.get('extData');
-          this.selectedFeature.setStyle(
+        if (this.clickMarker) {
+          const selectData = this.clickMarker.get('extData');
+          this.clickMarker.setStyle(
             new Style({
               image: new Icon({
                 src: selectData.image,
@@ -178,8 +175,8 @@ export class olMap {
         }
         if (['1', '2'].includes(extData.type)) {
           // 多点位 单点
-          if (this.selectedFeature !== feature) {
-            this.selectedFeature = feature;
+          if (this.clickMarker !== feature) {
+            this.clickMarker = feature;
             feature.setStyle(
               new Style({
                 image: new Icon({
@@ -195,7 +192,7 @@ export class olMap {
           }
         } else if (extData.type === '3') {
           // 聚合要素
-          this.select.getFeatures().clear();
+          // this.select.getFeatures().clear();
           const currentZoom = this.map.getView().getZoom();
           this.map.getView().setZoom(currentZoom + 1);
           this.map.getView().setCenter([Number(extData.longitude), Number(extData.latitude)]);
@@ -208,7 +205,11 @@ export class olMap {
     // 添加新的图层
     if (Array.isArray(options.id)) {
       for (const layer of options.id) {
-        await this.formatXml(layer);
+        if (layer.layerType === 'JSON') {
+          await this.createJsonLayer(layer);
+        } else {
+          await this.formatXml(layer);
+        }
       }
     } else if (options.id === 'tianditu') {
       await this.formatXml2();
@@ -253,28 +254,40 @@ export class olMap {
   }
   formatXml(options) {
     const xml = new WMTSCapabilities();
-    return this.getCapabilities(options.code).then((res) => {
-      const geoJson = xml.read(res.data);
-      const data = geoJson.Contents.Layer[0];
-      const layerParam = {
-        layerName: data.Abstract,
-        styleName: data.Identifier,
-        tilematrixset: data.TileMatrixSetLink[0].TileMatrixSet,
-        format: data.Format[0]
-      };
-      this.createWmsLayer(options, layerParam);
+    return this.getCapabilities(options.code, options.layerType).then((res) => {
+      if (options.layerType === 'WMTS') {
+        const geoJson = xml.read(res.data);
+        const data = geoJson.Contents.Layer[0];
+        const layerParam = {
+          layerName: data.Abstract,
+          styleName: data.Identifier,
+          tilematrixset: data.TileMatrixSetLink[0].TileMatrixSet,
+          format: data.Format[0]
+        };
+        this.createWmtsLayer(options, layerParam);
+      } else if (options.layerType === 'WFS') {
+        const parser = new DOMParser();
+        const xmlDoc = parser.parseFromString(res.data, 'text/xml');
+        const featureType = xmlDoc.getElementsByTagName('FeatureType')[0];
+        const layerParam = {
+          layerName: featureType.getElementsByTagName('Title')[0].textContent,
+          typeName: featureType.getElementsByTagName('Name')[0].textContent,
+          srsName: featureType.getElementsByTagName('SRS')[0].textContent
+        };
+        this.createWfsLayer(options, layerParam);
+      }
     });
   }
 
   // 请求接口获取地图信息
-  getCapabilities(code) {
-    return axios.get(commonUrl + code + '?SERVICE=WMTS&REQUEST=GetCapabilities', {
+  getCapabilities(code, service) {
+    return axios.get(commonUrl + code + '?SERVICE=' + service + '&REQUEST=GetCapabilities', {
       headers: globalHeaders()
     });
   }
 
-  // 请求地图图片加载图层
-  createWmsLayer(options, layerParam) {
+  // 请求WMTS地图图片加载图层
+  createWmtsLayer(options, layerParam) {
     const source = new WMTS({
       url: commonUrl + options.code,
       crossOrigin: 'Anonymous',
@@ -323,7 +336,50 @@ export class olMap {
     layer.set('id', options.code);
     this.map.addLayer(layer);
   }
+  //
+  createWfsLayer(options, layerParam) {
+    const source = new VectorSource({
+      format: new GeoJSON(),
+      url: `${commonUrl}${options.code}?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&typeName=流域:GEO_BAS_POLYGON&outputFormat=application/json& srsName=EPSG:4490`
+    });
+
+    const vectorLayer = new VectorLayer({
+      source: source,
+      style: new Style({
+        fill: new Fill({
+          color: 'rgba(255, 255, 255, 0.6)'
+        }),
+        stroke: new Stroke({
+          color: '#319FD3',
+          width: 1
+        })
+      })
+    });
 
+    this.map.addLayer(vectorLayer);
+  }
+  // 加载json图层
+  createJsonLayer(layer) {
+    return new Promise((resolve, reject) => {
+      const geojsonParser = new GeoJSON();
+      console.log(this.map.getView().getProjection());
+      const features = geojsonParser.readFeatures(gdJson, {
+        dataProjection: 'EPSG:4326',
+        featureProjection: this.map.getView().getProjection()
+      });
+      const jsonLayer = new VectorLayer({
+        source: new VectorSource({ features }),
+        style: new Style({
+          // 必须设置样式才能显示
+          fill: new Fill({ color: '#ffffff' }),
+          stroke: new Stroke({ color: 'rgba(0,0,0, 1)', width: 1 })
+        }),
+        zIndex: layer.zIndex ? layer.zIndex : -99
+      });
+      this.map.addLayer(jsonLayer);
+      resolve({});
+    });
+  }
   // 初始化绘画工具
   initMouseTool(options) {
     this.drawOptions = {
@@ -754,7 +810,7 @@ export class olMap {
       const name = key === 'search' ? 'search' : 'point';
       if (this.clickMarker) {
         const extData = this.clickMarker.get('extData');
-        if (data.id === extData.id) {
+        if (data.id === extData.id && data.dataType === extData.dataType) {
           hideInfoFlag = false;
           data.isHover = true;
         }
@@ -834,12 +890,13 @@ export class olMap {
             })
           );
           this.plotLayers[name].getSource().addFeature(feature);
+          if (data.isHover) {
+            this.clickMarker = feature;
+            this.options.onMarkerClick(data);
+          }
         };
         img.src = data.image; // 设置图片的 URL,触发加载
         this.markers.push(data);
-        if (data.isHover) {
-          this.options.onMarkerClick(data);
-        }
       }
     });
     if (hideInfoFlag) {
@@ -907,22 +964,20 @@ export class olMap {
   hideInfo(flag?: boolean) {
     this.map.removeOverlay(this.infoWindow);
     this.infoWindow = null;
-    if (!!flag && this.select) {
-      this.select.getFeatures().clear();
-      if (this.selectedFeature) {
-        const selectData = this.selectedFeature.get('extData');
-        this.selectedFeature.setStyle(
-          new Style({
-            image: new Icon({
-              src: selectData.image,
-              scale: selectData.scale,
-              anchor: [0.5, 0.5],
-              anchorXUnits: 'fraction',
-              anchorYUnits: 'fraction'
-            })
+    if (!!flag && this.clickMarker) {
+      const selectData = this.clickMarker.get('extData');
+      this.clickMarker.setStyle(
+        new Style({
+          image: new Icon({
+            src: selectData.image,
+            scale: selectData.scale,
+            anchor: [0.5, 0.5],
+            anchorXUnits: 'fraction',
+            anchorYUnits: 'fraction'
           })
-        );
-      }
+        })
+      );
+      this.clickMarker = null;
     }
   }
   /**

+ 6 - 0
src/views/comprehensiveGuarantee/electronicDisasterMapManage/index.vue

@@ -1216,4 +1216,10 @@ onUnmounted(() => {
   width: 25px;
   height: 34px;
 }
+:deep(.amap-info-content) {
+  padding: 0 !important;
+}
+:deep(.amap-info-close) {
+  display: none;
+}
 </style>

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov