wujingjing
2025-04-02 7866aa30bd13dab1fc0662e1baf6675d0dc1b282
src/model/map/OLMap.ts
@@ -1,12 +1,16 @@
import axios from 'axios';
import { defaultsDeep } from 'lodash-es';
import type { Feature, Overlay } from 'ol';
import { Map as OpenLayerMap, View } from 'ol';
import type { Overlay } from 'ol';
import { Feature, Map as OpenLayerMap, View } from 'ol';
import type { Extent } from 'ol/extent';
import { getTopLeft, getWidth } from 'ol/extent';
import { extend, getCenter, getTopLeft, getWidth } from 'ol/extent';
import type { FeatureLike } from 'ol/Feature';
import MVT from 'ol/format/MVT.js';
import WKT from 'ol/format/WKT';
import { Point } from 'ol/geom';
import type Geometry from 'ol/geom/Geometry';
import { defaults as olDefaults } from 'ol/interaction';
import { Draw, defaults as olDefaults } from 'ol/interaction';
import { createBox } from 'ol/interaction/Draw';
import type Layer from 'ol/layer/Layer';
import Tile from 'ol/layer/Tile';
import VectorLayer from 'ol/layer/Vector';
@@ -23,22 +27,24 @@
import type { ViewOptions } from 'ol/View';
import type { Ref, ShallowRef } from 'vue';
import { markRaw, ref } from 'vue';
import { MarkerOverlay } from './overlay/marker';
import { Logger } from '../logger/Logger';
import axios from 'axios';
import WKT from 'ol/format/WKT';
import { MarkerOverlay } from './overlay/marker';
import { getCurrentPosition } from '/@/utils/brower';
import { travelTree } from '/@/utils/util';
import { ElLoadingService } from 'element-plus';
import { switchMapTheme } from '/@/api/map';
import { formatDate } from '/@/utils/formatTime';
export type LangType = 'zh_cn' | 'en';
export const enum GaoDeSourceType {
   /** @description 默认地图 */
   Default = 0,
   Default = 'default',
   /** @description 影像地图 */
   Satellite = 1,
   Satellite = 'satellite',
   /** @description 矢量地图 */
   Vector = 2,
   Vector = 'standard',
   /** @description 影像路网 */
   SatelliteRoad = 3,
   SatelliteRoad = 'road_network',
}
export const enum OverlayType {
   Marker = 'marker',
@@ -86,6 +92,9 @@
   /** @description 图层控制信息 */
   layerInfo = ref([] as any[]);
   /** @description 图层控制信息 */
   legendList = ref([] as any[]);
   drawStyles = ref([] as any[]);
@@ -162,21 +171,79 @@
   gaodeApiKey = 'eea6302da02576fe3f3dd3ba1fbe0a04';
   locationLayer: VectorLayer<VectorSource<Feature<Geometry>>, Feature<Geometry>> = null;
   centerLayer: VectorLayer<VectorSource<Feature<Geometry>>, Feature<Geometry>> = null;
   async locationCurrent() {
      const position = await getCurrentPosition();
      if (!position) return;
      const { latitude, longitude } = position;
      return;
      const url = `https://restapi.amap.com/v5/ip/location?key=${this.gaodeApiKey}`;
      const response = await axios.get(url);
      this.map.getView().setCenter(fromLonLat([longitude, latitude]));
      this.map.getView().setZoom(15);
      // 移除旧图层
      this.map.removeLayer(this.locationLayer);
      this.map.removeLayer(this.centerLayer);
      // 创建定位点图层
      this.locationLayer = new VectorLayer({
         source: new VectorSource({
            features: [
               new Feature({
                  geometry: new Point(fromLonLat([longitude, latitude])),
               }),
            ],
         }),
         style: new Style({
            // 外圆
            image: new Circle({
               radius: 20,
               fill: new Fill({
                  color: 'rgba(24, 144, 255, 0.1)',
               }),
               stroke: new Stroke({
                  color: 'rgba(24, 144, 255, 0.3)',
                  width: 2,
               }),
            }),
         }),
         minZoom: 12,
      });
      // 创建中心点图层
      this.centerLayer = new VectorLayer({
         source: new VectorSource({
            features: [
               new Feature({
                  geometry: new Point(fromLonLat([longitude, latitude])),
               }),
            ],
         }),
         style: new Style({
            // 内圆
            image: new Circle({
               radius: 6,
               fill: new Fill({
                  color: '#1890ff',
               }),
               stroke: new Stroke({
                  color: '#fff',
                  width: 2,
               }),
            }),
         }),
      });
      // 添加新图层
      this.map.addLayer(this.locationLayer);
      this.map.addLayer(this.centerLayer);
      return position;
   }
   async gaodeAddressSearch(address) {
   async gaodeAddressSearch(address, city) {
      this.gaodeApiKey = 'eea6302da02576fe3f3dd3ba1fbe0a04';
      // const url = `https://restapi.amap.com/v3/assistant/inputtips?output=json&city=010&keywords=${address}=${this.gaodeApiKey}`;
      // 搜索 POI
      const url = `https://restapi.amap.com/v3/place/text?keywords=${address}&city=fuzhou&offset=20&page=1&key=${this.gaodeApiKey}&extensions=all `;
      const url = `https://restapi.amap.com/v3/place/text?keywords=${address}&city=${city}&offset=20&page=1&key=${this.gaodeApiKey}&extensions=all `;
      // 搜索 POI 2.0
      // const url = `https://restapi.amap.com/v5/place/text?keywords=${address}&city=beijing&offset=20&page=1&key=${this.gaodeApiKey}&extensions=all
@@ -184,73 +251,154 @@
      return response.data;
   }
   displaySearchResult(resultList) {
      // resultList = [
      //    {
      //       OTYPE: 'WDM_JUNCTIONS',
      //       ONAME: 'd7513894-38d2-48b5-884a-f9a16fe1298a',
      //       WKT: 'SRID=3857;POINT(13280607.09109455 3009899.678848996)',
      //    },
      //    {
      //       OTYPE: 'WDM_JUNCTIONS',
      //       ONAME: 'f2cbc0f8-de84-449e-9996-8b9425ea8438',
      //       WKT: 'SRID=3857;POINT(13274453.007984176 3006699.498741431)',
      //    },
      //    {
      //       OTYPE: 'WDM_JUNCTIONS',
      //       ONAME: '2a08d246-639e-4169-862f-38bda3e98677',
      //       WKT: 'SRID=3857;POINT(13285466.77807223 3016023.513009545)',
      //    },
      //    {
      //       OTYPE: 'WDM_JUNCTIONS',
      //       ONAME: '1bd4ea12-3a4c-4908-a73c-c5a8e14d20eb',
      //       WKT: 'SRID=3857;POINT(13282712.61192139 3016897.156892525)',
      //    },
      //    {
      //       OTYPE: 'WDM_JUNCTIONS',
      //       ONAME: 'e6d0c5cb-00f5-47aa-846f-0705de983364',
      //       WKT: 'SRID=3857;POINT(13288425.224571886 3006456.3830214837)',
      //    },
      //    {
      //       OTYPE: 'WDM_JUNCTIONS',
      //       ONAME: '6f83eff7-9e7b-46f8-8b1e-f18a69a98587_A',
      //       WKT: 'SRID=3857;POINT(13287645.018084045 3006696.595101201)',
      //    },
      //    {
      //       OTYPE: 'WDM_JUNCTIONS',
      //       ONAME: 'acc43afb-7c59-44f2-a36d-0d22eb1b4594_A',
      //       WKT: 'SRID=3857;POINT(13286166.586277477 3009094.237136173)',
      //    },
      //    {
      //       OTYPE: 'WDM_JUNCTIONS',
      //       ONAME: '8b449ce6-26ba-4c10-b18c-366ded424ec4',
      //       WKT: 'SRID=3857;POINT(13282290.543926762 3016028.715200386)',
      //    },
      //    {
      //       OTYPE: 'WDM_JUNCTIONS',
      //       ONAME: 'a668fe7e-0d08-4cff-9045-1c27d14b9b61',
      //       WKT: 'SRID=3857;POINT(13278933.218610007 3014782.279195062)',
      //    },
      //    {
      //       OTYPE: 'WDM_JUNCTIONS',
      //       ONAME: '6ccacce7-c65d-42b8-b5be-4c15ff648f99',
      //       WKT: 'SRID=3857;POINT(13275888.24189473 3002108.7952906396)',
      //    },
      // ];
      const first = resultList[0];
      let features = [];
      if (first) {
         const firstWktStr = first.WKT;
         const srid = firstWktStr.match(/SRID=(\d+);/)?.[1];
         const standardWktStrList = resultList.map((item) => item.WKT.replace(/SRID=\d+;/, ''));
         features = standardWktStrList.map((wktStr) => {
            return new WKT().readFeature(wktStr, {
               dataProjection: `EPSG:${srid}`,
               // featureProjection: `EPSG:${srid}`,
            });
   readWKT(wktStr) {
      const srid = wktStr.match(/SRID=(\d+);/)?.[1];
      const standardWktStr = wktStr.replace(/SRID=\d+;/, '');
      const feature = new WKT().readFeature(standardWktStr, {
         dataProjection: `EPSG:${srid}`,
      });
      return feature;
   }
   drawLayer: VectorLayer<VectorSource<Feature<Geometry>>, Feature<Geometry>> = null;
   private isDrawStatus = false;
   removeDrawLayer() {
      if (!this.drawLayer) return;
      this.map.removeLayer(this.drawLayer);
      this.drawLayer = null;
   }
   drawPolygon() {
      if (this.isDrawStatus) return;
      this.isDrawStatus = true;
      return new Promise((resolve) => {
         // 创建绘制交互
         const draw = new Draw({
            type: 'Polygon',
         });
      }
      this.highlightSearch(features);
         // 添加绘制交互到地图
         this.map.addInteraction(draw);
         // 监听绘制完成事件
         draw.on('drawend', (event) => {
            const feature = event.feature;
            const geometry = feature.getGeometry();
            const extent = geometry.getExtent();
            this.drawLayer = new VectorLayer({
               source: new VectorSource({
                  features: [feature],
               }),
               style: new Style({
                  stroke: new Stroke({
                     color: '#1677ff',
                     width: 2,
                  }),
                  fill: new Fill({
                     color: 'rgba(22, 119, 255, 0.1)',
                  }),
               }),
            });
            // 添加多边形图层到地图
            this.map.addLayer(this.drawLayer);
            // 移除绘制交互
            this.map.removeInteraction(draw);
            setTimeout(() => {
               this.isDrawStatus = false;
            }, 300);
            // 返回范围
            resolve(extent);
         });
      });
   }
   drawRectangle() {
      if (this.isDrawStatus) return;
      this.isDrawStatus = true;
      return new Promise((resolve) => {
         // 创建绘制交互
         const draw = new Draw({
            type: 'Circle',
            geometryFunction: createBox(),
         });
         // 添加绘制交互到地图
         this.map.addInteraction(draw);
         // 监听绘制完成事件
         draw.on('drawend', (event) => {
            const feature = event.feature;
            const geometry = feature.getGeometry();
            const extent = geometry.getExtent();
            this.drawLayer = new VectorLayer({
               source: new VectorSource({
                  features: [feature],
               }),
               style: new Style({
                  stroke: new Stroke({
                     color: '#1677ff',
                     width: 2,
                  }),
                  fill: new Fill({
                     color: 'rgba(22, 119, 255, 0.1)',
                  }),
               }),
            });
            // 添加新的feature
            // this.drawLayer.getSource().addFeature(feature);
            // 添加矩形图层到地图
            this.map.addLayer(this.drawLayer);
            // 移除绘制交互
            this.map.removeInteraction(draw);
            setTimeout(() => {
               this.isDrawStatus = false;
            }, 300);
            // 返回范围
            resolve(extent);
         });
      });
   }
   clearObjectSearch() {
      this.highlightSearch([]);
   }
   displaySearchResult(searchItem) {
      if (!searchItem?.WKT) return;
      const feature = this.readWKT(searchItem.WKT);
      this.highlightSearch(feature);
      const geometry = feature.getGeometry();
      this.map.getView().fit(geometry.getExtent(), {
         // padding: [100, 100, 100, 100],
         maxZoom: 15,
      });
      return feature;
   }
   zoomToFeatures(features) {
      if (features.length === 0) return;
      // 获取所有 feature 的最小外接矩形
      const extent = features.reduce((acc, feature) => {
         const featureExtent = feature.getGeometry().getExtent();
         if (!acc) return featureExtent;
         return extend(acc, featureExtent);
      }, null);
      // 调整视图以适应最小外接矩形
      this.map.getView().fit(extent, {
         maxZoom: 15,
         padding: [50, 50, 50, 50], // 添加内边距使视图更美观
      });
   }
   updateSize() {
      this.map.updateSize();
   }
   initEvent() {
@@ -259,6 +407,7 @@
         const zoom = that.map.getView().getZoom(); //获取当前地图的缩放级别
         Logger.info('当前地图缩放级别为:' + zoom);
      });
      this.pointermove();
   }
   hightLightColor: '0000FFFF';
@@ -554,6 +703,7 @@
      overlay.set('type', OverlayType.Marker);
      // 添加点击事件
      markerImg.addEventListener('click', (event) => {
         if (this.isDrawStatus) return;
         if (markerOpt.icon.selectUrl) {
            markerImg.src = markerOpt.icon.selectUrl;
         }
@@ -563,18 +713,23 @@
      return overlay;
   }
   adjustViewToMarkers() {
   getAllMarkerOverlays() {
      const overlays = this.map.getOverlays().getArray();
      const filteredOverlays = overlays.filter((overlay) => {
         const type = overlay.get('type');
         return type === OverlayType.Marker;
      });
      this.adjustViewToOverlays(filteredOverlays);
      return overlays.filter((overlay) => overlay.get('type') === OverlayType.Marker);
   }
   adjustViewToOverlays(overlays: Overlay[]) {
      if (overlays.length === 0) return;
   adjustViewToMarkers() {
      const overlays = this.getAllMarkerOverlays();
      this.adjustViewToOverlays(overlays);
   }
   getAllMarkerOverlaysExtent() {
      const overlays = this.getAllMarkerOverlays();
      const extent = this.getOverlaysExtent(overlays);
      return extent;
   }
   getOverlaysExtent(overlays: Overlay[]) {
      const extent = overlays.reduce<number[] | null>((ext, item) => {
         const coord = item.getPosition();
@@ -583,7 +738,12 @@
         }
         return [Math.min(ext[0], coord[0]), Math.min(ext[1], coord[1]), Math.max(ext[2], coord[0]), Math.max(ext[3], coord[1])];
      }, null);
      return extent;
   }
   adjustViewToOverlays(overlays: Overlay[]) {
      if (overlays.length === 0) return;
      const extent = this.getOverlaysExtent(overlays);
      if (extent) {
         this.fitExtend(extent);
      }
@@ -601,6 +761,7 @@
    */
   listenMapClick() {
      this.map.on('click', (event) => {
         if (this.isDrawStatus) return;
         // const features = this.map.getFeaturesAtPixel(event.pixel);
         const features = [];
         const layers: Layer<Source, LayerRenderer<any>>[] = [];
@@ -609,15 +770,24 @@
            layers.push(layer);
         });
         const feature = features[0];
         feature?.get('click')?.(event);
         const layer = layers[0];
         if (layer === this.drawLayer) return;
         this.labelOverlay?.setVisible(false);
         if (feature !== this.activeFeature.value) {
            this.emit('featureChange', feature, layer);
         }
         if (feature) {
            const otype = feature.get('otype');
            console.log('🚀 ~ otype:', otype);
            const oname = feature.get('oname');
            console.log('🚀 ~ oname:', oname);
            const geometryType = feature.getGeometry().getType();
            console.log('🚀 ~ geometryType:', geometryType);
            const properties = feature.getProperties();
            console.log('🚀 ~ properties:', properties);
         }
         this.highlightSelect(feature);
         this.activeFeature.value = feature;
@@ -639,6 +809,30 @@
      return allLayers;
   }
   zoomToLayers() {
      let extent = this.getAllMarkerOverlaysExtent();
      const layers = this.getAllLayerModels();
      if (layers.length > 0) {
         // 获取所有图层的范围
         extent = layers.reduce((extent, layer) => {
            const layerExtent = layer.getExtent();
            if (!extent) {
               return layerExtent;
            }
            // 合并范围
            return extend(extent, layerExtent);
         }, extent);
      }
      // 聚焦到合并后的范围
      this.map.getView().fit(extent, {
         padding: [50, 50, 50, 50],
         maxZoom: 15,
      });
   }
   getAllLayerModels() {
      return this.layerInfo.value.reduce((preVal, curVal) => {
         if (curVal.children && curVal.children.length > 0) {
@@ -647,6 +841,189 @@
            return preVal;
         }
      }, []);
   }
   setLayerVisible(layerId: string, visible: boolean) {
      const layer = this.getAllLayers().find((item) => item.id === layerId);
      if (layer) {
         layer.isVisible = visible;
      }
   }
   setThemeById(themeId: string) {
      let group;
      let theme;
      travelTree(this.themeInfo.value, (item, index, array, parent) => {
         if (item.type === 'theme' && item.id === themeId) {
            group = parent;
            theme = item;
            return true;
         }
      });
      if (group) {
         group.activeTheme = themeId;
         this.handleThemeChange(themeId, group);
      }
   }
   async changeTheme(ids: string) {
      const loadingInstance = ElLoadingService({
         text: '加载主题中...',
         target: '.layout-parent',
      });
      const res = await switchMapTheme({
         theme_id: ids,
         time: formatDate(new Date()),
      }).finally(() => {
         loadingInstance.close();
      });
      // 加入主题之后的样式函数
      const themeLayerStyleFunc = (feature, resolution) => {
         const otype = feature.get('otype');
         const oname = feature.get('oname');
         // oname 映射样式
         const onameStyleMap = res?.[`O_${otype}`] ?? {};
         const themeStyles = res?.styles ?? [];
         const styleIndex = onameStyleMap[oname]?.style_id;
         const themeStyle = styleIndex == null ? null : themeStyles[styleIndex];
         // if(themeStyle){
         // }
         const shape = feature.getGeometry().getType();
         const styles = [];
         switch (shape) {
            case 'Point':
               const pSize = themeStyle?.PSIZE ?? feature.get('psize');
               const pcolor = themeStyle?.PCOLOR ?? feature.get('pcolor');
               const pStyle = themeStyle?.PSTYLE ?? feature.get('pstyle');
               const pointStyle = this.getPointStyles({
                  size: pSize,
                  color: pcolor,
                  style: pStyle,
               });
               pointStyle && styles.push(pointStyle);
               break;
            case 'LineString':
               const lSize = themeStyle?.LSIZE ?? feature.get('lsize');
               const lColor = themeStyle?.LCOLOR ?? feature.get('lcolor');
               const lStyle = themeStyle?.LSTYLE ?? feature.get('lstyle');
               const pSize1 = themeStyle?.PSIZE ?? feature.get('psize');
               const pcolor1 = themeStyle?.PCOLOR ?? feature.get('pcolor');
               const pStyle1 = themeStyle?.PSTYLE ?? feature.get('pstyle');
               const lineStyle = this.getLineStyles({
                  lsize: lSize,
                  lcolor: lColor,
                  lstyle: lStyle,
                  psize: pSize1,
                  pcolor: pcolor1,
                  pstyle: pStyle1,
               });
               lineStyle && styles.push(...lineStyle);
               break;
            case 'Polygon':
               const pColor = themeStyle?.PCOLOR ?? feature.get('pcolor');
               const lSize1 = themeStyle?.LSIZE ?? feature.get('lsize');
               const lColor1 = themeStyle?.LCOLOR ?? feature.get('lcolor');
               const lstyle1 = themeStyle?.LSTYLE ?? feature.get('lstyle');
               const polygonStyle = this.getPolygonStyles({
                  pcolor: pColor,
                  lsize: lSize1,
                  lcolor: lColor1,
                  lstyle: lstyle1,
               });
               polygonStyle && styles.push(...polygonStyle);
               break;
            default:
               break;
         }
         // switch (otype) {
         //    case 'WDM_JUNCTIONS':
         //       const textStyle = createTextStyle(feature, resolution);
         //       styles.push(textStyle);
         //    case 'WDM_PIPES':
         //       break;
         // }
         //#region ====================== 添加标注 ======================
         const tString = themeStyle?.TSTRING ?? feature.get('tstring');
         const tStringStyle = this.getLabelStyles({
            textContent: tString,
            resolution,
         });
         tStringStyle && styles.push(tStringStyle);
         //#endregion
         return styles;
      };
      const allLayers = this.getAllLayers();
      for (const item of allLayers) {
         if (this.unsupportedLayers.includes(item.id)) {
            continue;
         }
         item.model.setStyle(themeLayerStyleFunc);
      }
      return res?.legends ?? [];
   }
   async handleThemeChange(val?, themeGroup?) {
      const allIds = [];
      for (const item of this.themeInfo.value) {
         if (item.activeTheme) {
            allIds.push(item.activeTheme);
         }
      }
      const ids = allIds.join(',');
      if (!ids) {
         const allLayers = this.getAllLayerModels();
         for (const item of allLayers) {
            const originStyle = item.get('originStyle');
            originStyle && item.setStyle(originStyle);
         }
         return;
      }
      const legends = await this.changeTheme(ids);
      this.legendList.value = this.parseLegends(legends);
   }
   parseLegends(legends) {
      const result = legends.map((item) => {
         const isEqual = item.operate === '=';
         const result = {
            ...item,
            legend: item.legend.map((legendItem, index, array) => {
               const preItem = array[index - 1];
               let label = '';
               if (isEqual) {
                  label = legendItem.value;
               } else if (preItem) {
                  label = `>${preItem.value}且${item.operate}${legendItem.value}`;
               } else {
                  label = `${item.operate}${legendItem.value}`;
               }
               return {
                  ...legendItem,
                  label: label,
               };
            }),
         };
         result.legend.push({
            style: item.default,
            value: '',
            label: result.legend.length == 0 ? '默认' : `>${item.legend[item.legend.length - 1].value}`,
         });
         return result;
      });
      return result;
   }
   /** @description 记录所有图层 */
@@ -764,19 +1141,59 @@
   /**
    * 放大地图
    */
   zoomIn() {
   zoomIn(offsetLevel = 1) {
      const view = this.map.getView();
      const zoom = view.getZoom();
      view.setZoom(zoom + 1);
      view.setZoom(zoom + offsetLevel);
   }
   /**
    * 缩小地图
    */
   zoomOut() {
   zoomOut(offsetLevel = 1) {
      const view = this.map.getView();
      const zoom = view.getZoom();
      view.setZoom(zoom - 1);
      view.setZoom(zoom - offsetLevel);
   }
   /**
    * 地图左移
    */
   panLeft(offset = 1000) {
      const view = this.map.getView();
      const center = view.getCenter();
      if (!center) return;
      view.setCenter([center[0] - offset, center[1]]);
   }
   /**
    * 地图右移
    */
   panRight(offset = 1000) {
      const view = this.map.getView();
      const center = view.getCenter();
      if (!center) return;
      view.setCenter([center[0] + offset, center[1]]);
   }
   /**
    * 地图上移
    */
   panUp(offset = 1000) {
      const view = this.map.getView();
      const center = view.getCenter();
      if (!center) return;
      view.setCenter([center[0], center[1] + offset]);
   }
   /**
    * 地图下移
    */
   panDown(offset = 1000) {
      const view = this.map.getView();
      const center = view.getCenter();
      if (!center) return;
      view.setCenter([center[0], center[1] - offset]);
   }
   private tileUrlFunction(url) {
@@ -979,11 +1396,85 @@
      }
   }
   private labelOverlay: MarkerOverlay = null;
   private initLabelOverlay() {
      if (this.labelOverlay) return;
      // 创建一个 div 元素用于显示标签
      const labelElement = document.createElement('div');
      labelElement.className = 'ol-label-overlay';
      labelElement.style.position = 'relative';
      labelElement.style.background = 'rgba(0,0,0,0.6)';
      labelElement.style.borderRadius = '4px';
      labelElement.style.color = '#fff';
      labelElement.style.padding = '4px 8px';
      labelElement.style.whiteSpace = 'nowrap';
      labelElement.style.fontSize = '12px';
      labelElement.style.transform = 'translate(-50%, -100%)';
      labelElement.style.marginBottom = '8px';
      // 创建 overlay
      this.labelOverlay = new MarkerOverlay({
         element: labelElement,
         offset: [0, 0],
         positioning: 'bottom-center',
      });
      // 添加到地图
      this.map.addOverlay(this.labelOverlay);
   }
   private preSearchHighlightFeatures: Feature[] = [];
   highlightSearch(features) {
      if (!Array.isArray(features)) {
         features = [features];
      }
      const positionFeatures = features.map((feature, index, array) => {
         const geometry = feature.getGeometry();
         const center = geometry.getExtent ? getCenter(geometry.getExtent()) : geometry.getCoordinates();
         // 创建一个新的Feature用于显示字体图标
         const iconFeature = new Feature({
            geometry: new Point(center),
         });
         // 设置字体图标样式
         // 添加点击事件监听
         // iconFeature.set('click', (event) => {
         //    // 初始化 labelOverlay
         //    this.initLabelOverlay();
         //    // 获取点击位置的坐标
         //    const coordinate = event.coordinate;
         //    // 设置 labelOverlay 的内容和位置
         //    const element = this.labelOverlay.getElement();
         //    element.innerHTML = `第${index + 1}个位置`;
         //    this.labelOverlay.setPosition(coordinate);
         // });
         iconFeature.setStyle([
            new Style({
               text: new Text({
                  text: '\ue642', // 使用字体图标的unicode编码
                  font: '24px "ywifont"', // 设置字体大小和字体名称
                  fill: new Fill({
                     color: '#1677ff',
                  }),
                  offsetY: -20, // 调整图标位置
               }),
            }),
            new Style({
               text: new Text({
                  text: array.length === 1 ? '' : index + 1, // 添加数字
                  font: '14px Arial', // 设置数字字体
                  fill: new Fill({
                     color: '#ffffff', // 数字颜色设为白色
                  }),
                  offsetY: -20, // 与图标保持相同的偏移
               }),
            }),
         ]);
         return iconFeature;
      });
      // 创建高亮图层
      if (!this.searchHighlightLayer) {
         this.searchHighlightLayer = new VectorLayer({
@@ -1000,11 +1491,26 @@
      }
      // 设置高亮要素
      if (features && features.length > 0) {
         this.searchHighlightLayer.getSource().addFeatures(features);
      if (positionFeatures && positionFeatures.length > 0) {
         this.searchHighlightLayer.getSource().addFeatures(positionFeatures);
      }
      this.preSearchHighlightFeatures = features;
      this.preSearchHighlightFeatures = positionFeatures;
   }
   pointermove() {
      this.map.on('pointermove', (e) => {
         if (this.map.hasFeatureAtPixel(e.pixel)) {
            this.map.getViewport().style.cursor = 'pointer';
         } else {
            this.map.getViewport().style.cursor = 'inherit';
         }
      });
   }
   clearMarker() {
      this.clearObjectSearch();
   }
   getWMTS = () => {
      const projection = getProjection('EPSG:3857');
      const projectionExtent = projection.getExtent();