From e50196bff10f0196307b2567ed6c0829eadd8ff6 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期一, 10 二月 2025 12:12:25 +0800
Subject: [PATCH] 设备显示隐藏

---
 src/model/map/OLMap.ts |  565 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 534 insertions(+), 31 deletions(-)

diff --git a/src/model/map/OLMap.ts b/src/model/map/OLMap.ts
index d972754..c9cbde8 100644
--- a/src/model/map/OLMap.ts
+++ b/src/model/map/OLMap.ts
@@ -1,13 +1,30 @@
 import { defaultsDeep } from 'lodash-es';
-import { Map as OpenLayerMap, Overlay, View } from 'ol';
+import type { Feature, Overlay } from 'ol';
+import { Map as OpenLayerMap, View } from 'ol';
 import type { Extent } from 'ol/extent';
 import { getTopLeft, getWidth } from 'ol/extent';
+import type { FeatureLike } from 'ol/Feature';
+import MVT from 'ol/format/MVT.js';
+import type Geometry from 'ol/geom/Geometry';
+import { defaults as olDefaults } from 'ol/interaction';
+import type Layer from 'ol/layer/Layer';
 import Tile from 'ol/layer/Tile';
+import VectorLayer from 'ol/layer/Vector';
+import VectorTileLayer from 'ol/layer/VectorTile';
 import { fromLonLat, get as getProjection } from 'ol/proj';
+import type LayerRenderer from 'ol/renderer/Layer';
+import type { Source } from 'ol/source';
 import { XYZ } from 'ol/source';
+import VectorSource from 'ol/source/Vector';
+import VectorTileSource from 'ol/source/VectorTile';
 import WMTS from 'ol/source/WMTS';
+import { Circle, Fill, Stroke, Style } from 'ol/style';
 import WMTSTileGrid from 'ol/tilegrid/WMTS';
 import type { ViewOptions } from 'ol/View';
+import type { Ref, ShallowRef } from 'vue';
+import { markRaw, ref } from 'vue';
+import { MarkerOverlay } from './overlay/marker';
+import { Text } from 'ol/style';
 
 export type LangType = 'zh_cn' | 'en';
 export const enum GaoDeSourceType {
@@ -20,12 +37,17 @@
 	/** @description 褰卞儚璺綉 */
 	SatelliteRoad = 3,
 }
+export const enum OverlayType {
+	Marker = 'marker',
+}
+export const MARKER_OVERLAY_CLASS_NAME = 'marker-overlay';
 
-export const GaoDeSourceTypeMap = {
-	[GaoDeSourceType.Default]: '榛樿鍦板浘',
-	[GaoDeSourceType.Satellite]: '褰卞儚鍦板浘',
-	[GaoDeSourceType.Vector]: '鐭㈤噺鍦板浘',
-	[GaoDeSourceType.SatelliteRoad]: '褰卞儚璺綉',
+export const gaoDeSourceTypeMap = {
+	// [GaoDeSourceType.Default]: '榛樿鍦板浘',
+	[GaoDeSourceType.Vector]: '鏍囧噯鍦板浘',
+
+	[GaoDeSourceType.Satellite]: '鍗槦鍦板浘',
+	[GaoDeSourceType.SatelliteRoad]: '璺綉鍦板浘',
 };
 
 export const getGaoDeSourceUrl = (type: GaoDeSourceType, lang: LangType = 'zh_cn') => {
@@ -37,20 +59,43 @@
 	};
 	return urlMap[type];
 };
+type MapConfig = {
+	sourceType: GaoDeSourceType;
+};
 
-type OLEventType = 'blackClick';
+type OLEventType = 'blackClick' | 'featureChange' | 'featureHoverChange';
 type OLMapOptions = {
 	container: HTMLDivElement;
 
 	view?: ViewOptions;
-};
+} & MapConfig;
+
+const resolutions = [];
+for (let i = 0; i <= 8; ++i) {
+	resolutions.push(156543.03392804097 / Math.pow(2, i * 2));
+}
 export class OLMap {
 	map: OpenLayerMap;
 	source: XYZ;
 	private eventMap: Map<OLEventType, Function[]>;
+	/** @description 鎺掗櫎鏈仛鐨刲ayer锛屽悗缁叏閮ㄥ仛濂斤紝鍙互涓嶅仛鍒ゆ柇 */
+	unsupportedLayers = [];
 
+	/** @description 鍥惧眰鎺у埗淇℃伅 */
+	layerInfo = ref([] as any[]);
+
+	drawStyles = ref([] as any[]);
+
+	/** @description 涓婚淇℃伅 */
+	themeInfo = ref([] as any[]);
+
+	activeSourceType: Ref<GaoDeSourceType> = ref(GaoDeSourceType.Vector);
+	interactLayer: VectorLayer<VectorSource<Feature<Geometry>>, Feature<Geometry>> = null;
+
+	/** @description 褰撳墠婵�娲荤姸鎬� feature */
+	activeFeature: ShallowRef<FeatureLike> = ref(null);
 	private emit(eventName: OLEventType, ...args: any[]) {
-		const handlers = this.eventMap.get(eventName);
+		const handlers = this.eventMap?.get(eventName);
 		if (handlers) {
 			handlers.forEach((handler) => handler(...args));
 		}
@@ -79,11 +124,12 @@
 	}
 
 	constructor(options: OLMapOptions) {
-		const { container, view } = defaultsDeep(options, {
+		const { container, view, sourceType } = defaultsDeep(options, {
 			view: {
 				center: [13247019.404399557, 4721671.572580107],
 				zoom: 8,
 			},
+			sourceType: GaoDeSourceType.Vector,
 		} as OLMapOptions) as OLMapOptions;
 		this.source = new XYZ({
 			crossOrigin: 'anonymous',
@@ -101,56 +147,259 @@
 			target: container, // 缁戝畾 DOM 瀹瑰櫒
 			layers: [layer], // 娣诲姞鍥惧眰
 			view: new View(view),
+			interactions: olDefaults({ doubleClickZoom: false }),
 		});
-		this.setSourceUrl();
+		this.activeSourceType.value = sourceType;
+		this.applySourceType(this.activeSourceType.value);
 		this.listenMapClick();
+		this.addBasicControl();
 	}
 
-	setSourceUrl(type: GaoDeSourceType = GaoDeSourceType.Vector) {
+	// 淇濆瓨鐐规牱寮忕紦瀛�
+	pointStyeMap: Record<string, Style> = {};
+
+	/**
+	 * 鏍规嵁鐐圭殑閰嶇疆鑾峰彇鏍峰紡
+	 * @param config
+	 * @returns
+	 */
+	getPointStyles(config: { size; color; style }) {
+		const pSize = config.size ?? 15;
+
+		const pcolor = config.color;
+		const pstyle = config.style;
+
+		const pkey = `${pstyle}_${pSize}_${pcolor}`;
+
+		if (!this.pointStyeMap[pkey]) {
+			const drawStyle = this.drawStyles.value.find((item) => item.id === pstyle + '');
+			const drawStyleType = drawStyle?.type;
+			const config = drawStyle?.config;
+
+			const drawStyleConfigType = drawStyle?.config?.type;
+			if (drawStyleType === 'POINT') {
+				if (drawStyleConfigType === 'circle') {
+					this.pointStyeMap[pkey] = new Style({
+						image: new Circle({
+							radius: pSize,
+							fill: new Fill({ color: `#${pcolor}` }),
+						}),
+					});
+				} else if (drawStyleConfigType === 'font') {
+					this.pointStyeMap[pkey] = new Style({
+						text: new Text({
+							font: `${pSize}px "ywifont"`,
+							text: config?.text ?? '',
+							fill: new Fill({ color: `#${pcolor}` }),
+						}),
+					});
+				} else {
+					this.pointStyeMap[pkey] = new Style({
+						image: new Circle({
+							radius: pSize,
+							fill: new Fill({ color: `#${pcolor}` }),
+						}),
+					});
+				}
+			} else {
+				this.pointStyeMap[pkey] = new Style({
+					image: new Circle({
+						radius: pSize,
+						fill: new Fill({ color: `#${pcolor}` }),
+					}),
+				});
+			}
+		}
+		return this.pointStyeMap[pkey];
+	}
+
+	// 淇濆瓨绾挎牱寮忕紦瀛�
+	lineStyleMap: Record<string, Style> = {};
+
+	/**
+	 * 鏍规嵁绾跨殑閰嶇疆鑾峰彇鏍峰紡
+	 * @param config
+	 */
+	getLineStyles(config: { lsize; lcolor; lstyle; psize?; pcolor?; pstyle? }) {
+		const lSize = config.lsize;
+		if (!lSize) return null;
+		const lColor = config.lcolor;
+		const lstyle = config.lstyle;
+		const styles = [];
+		const lKey = `${lstyle}_${lSize}_${lColor}`;
+		if (!this.lineStyleMap[lKey]) {
+			const drawStyle = this.drawStyles.value.find((item) => item.id === lstyle + '');
+			const drawStyleType = drawStyle?.type;
+			const config = drawStyle?.config;
+			this.lineStyleMap[lKey] = new Style({
+				// image: new Circle({
+				// 	radius: lsize,
+				// 	fill: new Fill({ color: `#${color}` }),
+				// }),
+				stroke: new Stroke({
+					color: `#${lColor}`,
+					width: lSize,
+				}),
+			});
+		}
+		styles.push(this.lineStyleMap[lKey]);
+
+		const hasPoint = Object.keys(config).some((key) => key === 'psize' && !!config[key]);
+		if (hasPoint) {
+			const psize = config.psize;
+			const pcolor = config.pcolor;
+			const pstyle = config.pstyle;
+			const pointStyle = this.getPointStyles({ size: psize, color: pcolor, style: pstyle });
+			styles.push(pointStyle);
+		}
+		return styles;
+	}
+	polygonStyleMap: Record<string, Style> = {};
+	getPolygonStyles(config: { pcolor; lstyle; lsize; lcolor }) {
+		const styles = [];
+		const pColor = config.pcolor;
+		const key = pColor;
+		if (!this.polygonStyleMap[key]) {
+			const polygonStyle = new Style({
+				fill: new Fill({ color: `#${pColor}` }),
+			});
+			styles.push(polygonStyle);
+		}
+
+		const lineStyle = this.getLineStyles({
+			lsize: config.lsize,
+			lcolor: config.lcolor,
+			lstyle: config.lstyle,
+		});
+		lineStyle && styles.push(...lineStyle);
+		return styles;
+	}
+
+	private maxTextResolution = 1;
+	getText(textContent, resolution) {
+		let text = `${textContent}`;
+		if (resolution > this.maxTextResolution) {
+			text = '';
+		}
+
+		// else if (type == 'hide') {
+		// 	text = '';
+		// } else if (type == 'shorten') {
+		// 	text = text.trunc(12);
+		// } else if (type == 'wrap' && (!dom.placement || dom.placement.value != 'line')) {
+		// 	text = stringDivider(text, 16, '\n');
+		// }
+
+		return text;
+	}
+
+	createTextStyle(textContent, resolution) {
+		return new Style({
+			text: new Text({
+				text: this.getText(textContent, resolution),
+				font: '14px Arial',
+				fill: new Fill({ color: '#000' }),
+				stroke: new Stroke({ color: '#fff', width: 2 }),
+				offsetX: 10, // 鏂囧瓧鐩稿浜庡嚑浣曚腑蹇冪殑姘村钩鍋忕Щ
+				offsetY: 20, // 鏂囧瓧鐩稿浜庡嚑浣曚腑蹇冪殑鍨傜洿鍋忕Щ
+			}),
+		});
+	}
+
+	// 淇濆瓨鏍囩鏍峰紡缂撳瓨
+	labelStyleMap: Record<string, Style> = {};
+
+	/**
+	 * 鏍规嵁鏍囩鐨勯厤缃幏鍙栨牱寮�
+	 * @param config
+	 */
+	getLabelStyles(config: { textContent; resolution }) {
+		const textContent = config.textContent;
+		if (!textContent) return null;
+		const resolution = config.resolution;
+		if (!textContent) return null;
+		if (!this.labelStyleMap[textContent]) {
+			this.labelStyleMap[textContent] = this.createTextStyle(textContent, resolution);
+		}
+		return this.labelStyleMap[textContent];
+	}
+
+	setDrawStyles(styles: any[]) {
+		this.drawStyles.value = styles;
+	}
+
+	applySourceType(type: GaoDeSourceType = GaoDeSourceType.Vector) {
 		const url = getGaoDeSourceUrl(type);
 		this.source.setUrl(url);
+	}
+
+	setSourceType(type: GaoDeSourceType = GaoDeSourceType.Vector) {
+		this.activeSourceType.value = type;
+		this.applySourceType(type);
 	}
 	addMarkerLayer(dataList: any[], options: any) {
 		const { markerOpt } = options;
 		const markers: Overlay[] = [];
 
 		// 鍒涘缓鏍囪鐐�
-		dataList.forEach((item) => {
-			const marker = this.createMarker(item, markerOpt);
+		dataList.forEach((item, index) => {
+			const marker = this.createMarker(`marker-${index}`, item, markerOpt);
 			markers.push(marker);
 			this.map.addOverlay(marker);
 		});
 
 		// 璁$畻骞惰皟鏁磋鍥捐寖鍥�
-		this.adjustViewToMarkers(dataList);
+		this.adjustViewToOverlays(markers);
 	}
 
+
+	checkEquipIsShow() {
+		for (const item of this.layerInfo.value) {
+			if (item.id === 'equip') {
+				return item.isVisible;
+			}
+		}
+		return false;
+	}
+
+	getEquipOverlay() {
+		for (const item of this.layerInfo.value) {
+			if (item.type === 'equip') {
+				return item;
+			}
+			
+		}
+	}
 	createEleOverlay(dom: string | HTMLElement, position = [0, 0]) {
 		const ele = typeof dom === 'string' ? (document.querySelector(dom) as HTMLElement) : dom;
 		if (!ele) return;
-		const eleOverlay = new Overlay({
+		const eleOverlay = new MarkerOverlay({
 			element: ele,
 			position: position,
 			positioning: 'top-left',
 			stopEvent: false,
 			className: 'z-[999]',
 		});
-		// // 鐢变簬 setVisible 鏄彈淇濇姢鐨勬柟娉�,鏀圭敤 set('visible', true) 鏉ヨ缃彲瑙佹��
-		// eleOverlay.set('visible', true);
+		eleOverlay.setVisible(this.checkEquipIsShow());
+
 		return eleOverlay;
 	}
 
-	private createMarker(item: any, markerOpt: any): Overlay {
+	private createMarker(id: string, item: any, markerOpt: any): Overlay {
 		// 鍒涘缓鍥剧墖鍏冪礌
 		const markerImg = document.createElement('img');
 		markerImg.src = markerOpt.icon.url;
 		markerImg.style.width = `${markerOpt.icon.size}px`;
 		markerImg.style.height = `${markerOpt.icon.size}px`;
 		markerImg.style.cursor = 'pointer';
+		markerImg.style.userSelect = 'none';
+
 		const position = fromLonLat(item.position);
 
 		// 鍒涘缓 Overlay
-		const overlay = new Overlay({
+		const overlay = new MarkerOverlay({
+			id,
+			className: MARKER_OVERLAY_CLASS_NAME,
 			element: markerImg,
 			position: position,
 			positioning: 'center-center',
@@ -158,28 +407,39 @@
 		});
 
 		overlay.set('extData', item.extData);
+		overlay.set('type', OverlayType.Marker);
 		// 娣诲姞鐐瑰嚮浜嬩欢
 		markerImg.addEventListener('click', (event) => {
 			if (markerOpt.icon.selectUrl) {
 				markerImg.src = markerOpt.icon.selectUrl;
 			}
-			markerOpt.click?.(event, overlay, item, position);
+			markerOpt.click?.(event, overlay, item.extData, position);
 		});
 
 		return overlay;
 	}
 
-	private adjustViewToMarkers(dataList: any[]) {
-		// 璁$畻鎵�鏈夌偣鐨勮寖鍥�
-		const extent = dataList.reduce((ext, item) => {
-			const coord = fromLonLat(item.position);
+	adjustViewToMarkers() {
+		const overlays = this.map.getOverlays().getArray();
+
+		const filteredOverlays = overlays.filter((overlay) => {
+			const type = overlay.get('type');
+			return type === OverlayType.Marker;
+		});
+		this.adjustViewToOverlays(filteredOverlays);
+	}
+
+	adjustViewToOverlays(overlays: Overlay[]) {
+		if (overlays.length === 0) return;
+		const extent = overlays.reduce<number[] | null>((ext, item) => {
+			const coord = item.getPosition();
+
 			if (!ext) {
 				return [coord[0], coord[1], coord[0], coord[1]];
 			}
 			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);
 
-		// 璋冩暣瑙嗗浘浠ラ�傚簲鏍囪鐐硅寖鍥�
 		if (extent) {
 			this.fitExtend(extent);
 		}
@@ -193,19 +453,262 @@
 		});
 	}
 	/**
-	 * 鐩戝惉鍦板浘绌虹櫧鍖哄煙鐐瑰嚮
+	 * 鐩戝惉鍦板浘鐐瑰嚮
 	 */
 	listenMapClick() {
 		this.map.on('click', (event) => {
-			const feature = this.map.forEachFeatureAtPixel(event.pixel, (feature) => feature);
+			// const features = this.map.getFeaturesAtPixel(event.pixel);
+			const features = [];
+			const layers: Layer<Source, LayerRenderer<any>>[] = [];
+			this.map.forEachFeatureAtPixel(event.pixel, (feature, layer) => {
+				features.push(feature);
+				layers.push(layer);
+			});
+			const feature = features[0];
+			const layer = layers[0];
+			if (feature !== this.activeFeature.value) {
+				this.emit('featureChange', feature, layer);
+			}
+			if (feature) {
+				console.log('馃殌 ~ feature:', 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.activeFeature.value = feature;
+			// this.displayFeatureInfo(feature);
+		});
+	}
 
-			if (!feature) {
-				// overlay 鏃犳硶鍒ゆ柇
-				this.emit('blackClick', event);
+	setAllThemes(themeInfo) {
+		this.themeInfo.value = themeInfo;
+	}
+
+	getAllLayers() {
+		const allLayers = this.layerInfo.value.reduce((preVal, curVal) => {
+			if (preVal.children && preVal.children.length > 0) {
+				return preVal.concat(curVal.children.map((item) => item));
+			} else {
+				return preVal;
+			}
+		}, []);
+		return allLayers;
+	}
+
+	getAllLayerModels() {
+		return this.layerInfo.value.reduce((preVal, curVal) => {
+			if (preVal.children && preVal.children.length > 0) {
+				return preVal.concat(curVal.children.map((item) => item.model));
+			} else {
+				return preVal;
+			}
+		}, []);
+	}
+
+	/** @description 璁板綍鎵�鏈夊浘灞� */
+	setAllLayers(layerModels: Layer[], layers: any[], layerGroup: any[]) {
+		// this.layerInfo.value = layerModels.map((layer, index) => {
+		// 	const layerData = layers[index];
+
+		// 	return {
+		// 		id: layerData.id,
+		// 		title: layerData.title,
+		// 		model: markRaw(layer),
+		// 		get isVisible() {
+		// 			return layer.getVisible();
+		// 		},
+		// 		set isVisible(val) {
+		// 			layer.setVisible(val);
+		// 		},
+		// 	};
+		// });
+		this.layerInfo.value = layerGroup.reduce((preVal, curVal) => {
+			const group = curVal.group;
+			const groupId = `group-${group}`;
+			let mapGroupItem = preVal.find((item) => item.id === groupId);
+			if (!mapGroupItem) {
+				mapGroupItem = { id: groupId, title: group, type: 'layer-group' };
+				preVal.push(mapGroupItem);
+			}
+			if (!mapGroupItem.children) {
+				mapGroupItem.children = [];
+			}
+			const layerId = curVal.layer_id;
+			const foundIndex = layers.findIndex((item) => item.id === layerId);
+			if (foundIndex === -1) {
+				return preVal;
+			}
+			const layer = layerModels[foundIndex];
+			const layerData = layers[foundIndex];
+			const data = {
+				id: layerData.id,
+				title: layerData.title,
+				model: markRaw(layer),
+				get isVisible() {
+					return layer.getVisible();
+				},
+				set isVisible(val) {
+					layer.setVisible(val);
+				},
+				type: 'layer',
+			};
+			mapGroupItem.children.push(data);
+			return preVal;
+		}, []);
+		const that = this;
+		this.layerInfo.value.push({
+			id: 'equip',
+			title: '鐩戞祴璁惧',
+			children: [],
+			_isVisible: true,
+			get isVisible() {
+				return this._isVisible;
+			},
+			set isVisible(val) {
+				console.log("馃殌 ~ val:", val)
+				this._isVisible = val;
+				that.toggleMarkerOverlayVisible(val);
+			},
+			type: 'equip',
+		});
+	}
+
+	/**
+	 *
+	 * 鐩戝惉鍦板浘瑕佺礌hover
+	 */
+	listenMapFeatureHover() {
+		let activeHover: FeatureLike = null;
+		this.map.on('pointermove', (event) => {
+			const features = this.map.getFeaturesAtPixel(event.pixel);
+			const feature = features[0];
+			if (feature !== activeHover) {
+				this.emit('featureHoverChange', feature);
+			}
+			activeHover = feature;
+		});
+	}
+
+	toggleMarkerOverlayVisible(visible: boolean) {
+		const overlays = this.map.getOverlays();
+		overlays.forEach((overlay) => {
+			if (overlay instanceof MarkerOverlay) {
+				const overlayElement = overlay.getElement();
+				if (overlayElement) {
+					overlayElement.style.visibility = visible ? 'visible' : 'hidden';
+				}
 			}
 		});
 	}
 
+	getConfig(): MapConfig {
+		return {
+			sourceType: this.activeSourceType.value,
+		};
+	}
+
+	setConfig(config: MapConfig) {
+		this.activeSourceType.value = config.sourceType;
+		this.applySourceType(this.activeSourceType.value);
+	}
+
+	private addBasicControl() {
+		// this.map.addControl(new ZoomSlider());
+		// this.map.addControl(new FullScreen());
+		const container = this.map.getViewport();
+		if (!container) return;
+		const olZoom = container.querySelector('.ol-zoom') as HTMLElement;
+		if (!olZoom) return;
+		olZoom.style.display = 'none';
+	}
+
+	/**
+	 * 鏀惧ぇ鍦板浘
+	 */
+	zoomIn() {
+		const view = this.map.getView();
+		const zoom = view.getZoom();
+		view.setZoom(zoom + 1);
+	}
+
+	/**
+	 * 缂╁皬鍦板浘
+	 */
+	zoomOut() {
+		const view = this.map.getView();
+		const zoom = view.getZoom();
+		view.setZoom(zoom - 1);
+	}
+
+	private tileUrlFunction(url) {
+		return (tileCoord) =>
+			url
+				.replace('{z}', String(tileCoord[0] * 2 - 1))
+				.replace('{x}', String(tileCoord[1]))
+				.replace('{y}', String(tileCoord[2]))
+				.replace('{a-d}', 'abcd'.substr(((tileCoord[1] << tileCoord[0]) + tileCoord[2]) % 4, 1));
+	}
+
+	addCustomLayer(url: string, style?: any) {
+		const vectorTileExtent = [13270414.528705932, 2994644.904997596, 13295641.139349712, 3018305.0256410106];
+
+		const vectorTileLayer = new VectorTileLayer({
+			source: new VectorTileSource({
+				format: new MVT(),
+				url: url,
+			}),
+			extent: vectorTileExtent,
+			style: style,
+		});
+		this.map.addLayer(vectorTileLayer);
+		return vectorTileLayer;
+	}
+
+	// highlightFeature = null;
+	displayFeatureInfo(feature) {
+		const highlightStyle = {
+			Point: new Style({
+				image: new Circle({
+					radius: 5,
+					fill: new Fill({ color: `blue` }),
+				}),
+			}),
+			LineString: new Style({
+				stroke: new Stroke({
+					color: `blue`,
+					width: 5,
+				}),
+			}),
+		};
+		// 鍒涘缓楂樹寒鍥惧眰
+		if (!this.interactLayer) {
+			this.interactLayer = new VectorLayer({
+				source: new VectorSource(),
+				map: this.map,
+				style: (feature) => {
+					const type = feature.getGeometry().getType();
+					return highlightStyle[type];
+				},
+			});
+		}
+
+		// 璁剧疆楂樹寒瑕佺礌
+		if (feature !== this.activeFeature.value) {
+			if (this.activeFeature.value) {
+				this.interactLayer.getSource().removeFeature(this.activeFeature.value as any);
+			}
+			if (feature) {
+				this.interactLayer.getSource().addFeature(feature);
+			}
+			// this.highlightFeature = feature;
+		}
+	}
+
 	getWMTS = () => {
 		const projection = getProjection('EPSG:3857');
 		const projectionExtent = projection.getExtent();

--
Gitblit v1.9.3