Hwf преди 3 месеца
родител
ревизия
01014601da
променени са 4 файла, в които са добавени 28 реда и са изтрити 19 реда
  1. 0 0
      src/assets/json/gd.json
  2. 1 1
      src/components/Map/YztMap/index.vue
  3. 0 15
      src/types/components.d.ts
  4. 27 3
      src/utils/olMap/olMap.ts

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
src/assets/json/gd.json


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

@@ -67,7 +67,7 @@ const mapList = reactive({
     { layer: 'annotation', code: 'YZT1695608158269', zIndex: '-98', visible: true }
     { layer: 'annotation', code: 'YZT1695608158269', zIndex: '-98', visible: true }
   ],
   ],
   imageMap2: [
   imageMap2: [
-    { layer: 'map', code: 'YZT1640925052482', zIndex: '-99', visible: true },
+    { layer: 'map', code: 'gd', zIndex: '-99', visible: true },
     { layer: 'annotation', code: 'YZT1695608158269', zIndex: '-98', visible: true }
     { layer: 'annotation', code: 'YZT1695608158269', zIndex: '-98', visible: true }
   ]
   ]
 });
 });

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

@@ -27,10 +27,8 @@ declare module 'vue' {
     ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
     ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
     ElBadge: typeof import('element-plus/es')['ElBadge']
     ElBadge: typeof import('element-plus/es')['ElBadge']
     ElButton: typeof import('element-plus/es')['ElButton']
     ElButton: typeof import('element-plus/es')['ElButton']
-    ElCol: typeof import('element-plus/es')['ElCol']
     ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
     ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
     ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
     ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
-    ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
     ElDialog: typeof import('element-plus/es')['ElDialog']
     ElDialog: typeof import('element-plus/es')['ElDialog']
     ElDivider: typeof import('element-plus/es')['ElDivider']
     ElDivider: typeof import('element-plus/es')['ElDivider']
     ElDrawer: typeof import('element-plus/es')['ElDrawer']
     ElDrawer: typeof import('element-plus/es')['ElDrawer']
@@ -38,27 +36,14 @@ declare module 'vue' {
     ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
     ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
     ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
     ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
     ElEmpty: typeof import('element-plus/es')['ElEmpty']
     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']
     ElIcon: typeof import('element-plus/es')['ElIcon']
-    ElInput: typeof import('element-plus/es')['ElInput']
     ElMenu: typeof import('element-plus/es')['ElMenu']
     ElMenu: typeof import('element-plus/es')['ElMenu']
     ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
     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']
     ElPopover: typeof import('element-plus/es')['ElPopover']
-    ElRow: typeof import('element-plus/es')['ElRow']
     ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
     ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
-    ElSelect: typeof import('element-plus/es')['ElSelect']
     ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
     ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
     ElSwitch: typeof import('element-plus/es')['ElSwitch']
     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']
     ElTooltip: typeof import('element-plus/es')['ElTooltip']
-    ElTree: typeof import('element-plus/es')['ElTree']
-    ElUpload: typeof import('element-plus/es')['ElUpload']
     ExcelEditor: typeof import('./../components/ExcelEditor/index.vue')['default']
     ExcelEditor: typeof import('./../components/ExcelEditor/index.vue')['default']
     FileUpload: typeof import('./../components/FileUpload/index.vue')['default']
     FileUpload: typeof import('./../components/FileUpload/index.vue')['default']
     FlvVideo: typeof import('./../components/FlvVideo/index.vue')['default']
     FlvVideo: typeof import('./../components/FlvVideo/index.vue')['default']

+ 27 - 3
src/utils/olMap/olMap.ts

@@ -22,12 +22,10 @@ import { defaults, ScaleLine } from 'ol/control';
 import Vector from 'ol/layer/Vector';
 import Vector from 'ol/layer/Vector';
 import SourceVector from 'ol/source/Vector';
 import SourceVector from 'ol/source/Vector';
 import GeoJSON from 'ol/format/GeoJSON';
 import GeoJSON from 'ol/format/GeoJSON';
-import { fromLonLat } from 'ol/proj';
 import axios from 'axios';
 import axios from 'axios';
 import { fromExtent } from 'ol/geom/Polygon';
 import { fromExtent } from 'ol/geom/Polygon';
 import { LinearRing, LineString, Polygon } from 'ol/geom';
 import { LinearRing, LineString, Polygon } from 'ol/geom';
 import { Graticule } from 'ol/layer';
 import { Graticule } from 'ol/layer';
-import { getPointsCenter, mergeGeoJsonPolygons } from '@/utils/gisUtils';
 import { Cluster } from 'ol/source';
 import { Cluster } from 'ol/source';
 import CircleStyle from 'ol/style/Circle';
 import CircleStyle from 'ol/style/Circle';
 import Overlay from 'ol/Overlay';
 import Overlay from 'ol/Overlay';
@@ -41,6 +39,7 @@ import { nanoid } from 'nanoid';
 import carImg from '@/assets/images/car.png';
 import carImg from '@/assets/images/car.png';
 import { globalHeaders } from '@/utils/request';
 import { globalHeaders } from '@/utils/request';
 import { iconList } from '@/views/globalMap/data/mapData';
 import { iconList } from '@/views/globalMap/data/mapData';
+import gdJson from '@/assets/json/gd.json';
 
 
 const tk = 'a8df87f1695d224d2679aa805c1268d9';
 const tk = 'a8df87f1695d224d2679aa805c1268d9';
 const commonUrl = import.meta.env.VITE_APP_BASE_API2 + 'api/oneShare/proxyHandler/gd/';
 const commonUrl = import.meta.env.VITE_APP_BASE_API2 + 'api/oneShare/proxyHandler/gd/';
@@ -208,7 +207,11 @@ export class olMap {
     // 添加新的图层
     // 添加新的图层
     if (Array.isArray(options.id)) {
     if (Array.isArray(options.id)) {
       for (const layer of options.id) {
       for (const layer of options.id) {
-        await this.formatXml(layer);
+        if (layer.code === 'gd') {
+          await this.initJsonLayer(layer);
+        } else {
+          await this.formatXml(layer);
+        }
       }
       }
     } else if (options.id === 'tianditu') {
     } else if (options.id === 'tianditu') {
       await this.formatXml2();
       await this.formatXml2();
@@ -324,6 +327,27 @@ export class olMap {
     this.map.addLayer(layer);
     this.map.addLayer(layer);
   }
   }
 
 
+  // 加载json图层
+  initJsonLayer(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: -100
+      });
+      this.map.addLayer(jsonLayer);
+      resolve({});
+    });
+  }
   // 初始化绘画工具
   // 初始化绘画工具
   initMouseTool(options) {
   initMouseTool(options) {
     this.drawOptions = {
     this.drawOptions = {

Някои файлове не бяха показани, защото твърде много файлове са промени