From 6e2557b3ae3e1b43bc01a5122f5fd4aa9b83d755 Mon Sep 17 00:00:00 2001
From: gerson <1405270578@qq.com>
Date: 星期日, 09 二月 2025 18:51:33 +0800
Subject: [PATCH] 整理绘制

---
 src/components/chat/chatComponents/summaryCom/components/recordSetTable/map/BasicMap.vue |   77 +++++++++++++++++---------------------
 1 files changed, 35 insertions(+), 42 deletions(-)

diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/map/BasicMap.vue b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/map/BasicMap.vue
index d47ad85..ba1a401 100644
--- a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/map/BasicMap.vue
+++ b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/map/BasicMap.vue
@@ -69,6 +69,7 @@
 import LayerControl from './LayerControl.vue';
 import PanelTool from './panelTool/index.vue';
 import {
+	getMapDrawStyles,
 	getMapLayerGroupList,
 	getMapLayersByPost,
 	getMapThemeList,
@@ -98,7 +99,6 @@
 		}),
 	}
 );
-
 
 const colsArray = computed(() => {
 	return props.data.cols ?? [];
@@ -273,9 +273,8 @@
 
 const maxResolution = 1;
 
-const getText = function (feature, resolution) {
-	const oname = feature.get('oname');
-	let text = `first-${oname[0]}`;
+const getText = function (textContent, resolution) {
+	let text = `${textContent}`;
 	if (resolution > maxResolution) {
 		text = '';
 	}
@@ -290,10 +289,10 @@
 
 	return text;
 };
-const createTextStyle = (feature, resolution) => {
+const createTextStyle = (textContent, resolution) => {
 	return new Style({
 		text: new Text({
-			text: getText(feature, resolution),
+			text: getText(textContent, resolution),
 			font: '14px Arial',
 			fill: new Fill({ color: '#000' }),
 			stroke: new Stroke({ color: '#fff', width: 2 }),
@@ -304,8 +303,8 @@
 };
 
 const styleMap: Record<string, Record<string, Style>> = {
-	junction: {},
-	pipe: {},
+	point: {},
+	line: {},
 	polygon: {},
 };
 /** @description 宸茬粡鍋氱殑layer锛屽悗缁叏閮ㄥ仛濂斤紝鍙互涓嶅仛鍒ゆ柇 */
@@ -316,41 +315,28 @@
 	switch (shape) {
 		case 'Point':
 			const pSize = feature.get('psize');
-			if (!pSize) return null;
 
 			const pcolor = feature.get('pcolor');
-			const pkey = `${pSize}_${pcolor}`;
+			const pstyle = feature.get('pstyle');
+			const pointStyle = olMap.value.getPointStyles({
+				size: pSize,
+				color: pcolor,
+				style: pstyle,
+			});
 
-			if (!styleMap.junction[pkey]) {
-				styleMap.junction[pkey] = new Style({
-					image: new Circle({
-						radius: pSize,
-						fill: new Fill({ color: `#${pcolor}` }),
-					}),
-				});
-			}
-
-			// const textStyle = createTextStyle(feature, resolution);
-			styles.push(styleMap.junction[pkey]);
+			styles.push(pointStyle);
 			break;
 		case 'LineString':
 			const lSize = feature.get('lsize');
-			if (!lSize) return null;
 			const lColor = feature.get('lcolor');
-			const lKey = `${lSize}_${lColor}`;
-			if (!styleMap.pipe[lKey]) {
-				styleMap.pipe[lKey] = new Style({
-					// image: new Circle({
-					// 	radius: lsize,
-					// 	fill: new Fill({ color: `#${color}` }),
-					// }),
-					stroke: new Stroke({
-						color: `#${lColor}`,
-						width: lSize,
-					}),
-				});
-			}
-			styles.push(styleMap.pipe[lKey]);
+			const lstyle = feature.get('lstyle');
+
+			const lineStyle = olMap.value.getLineStyles({
+				lsize: lSize,
+				lcolor: lColor,
+				lstyle: lstyle,
+			});
+			styles.push(...lineStyle);
 			break;
 		case 'Polygon':
 			break;
@@ -358,7 +344,6 @@
 			break;
 	}
 
-	const otype = feature.get('otype');
 	// switch (otype) {
 	// 	case 'WDM_JUNCTIONS':
 	// 		const textStyle = createTextStyle(feature, resolution);
@@ -369,9 +354,13 @@
 	// }
 	//#region ====================== 娣诲姞鏍囨敞 ======================
 	const tString = feature.get('tstring');
-	if (tString) {
-		const textStyle = createTextStyle(feature, resolution);
-		styles.push(textStyle);
+
+	const tStringStyle = olMap.value.getLabelStyles({
+		textContent: tString,
+		resolution,
+	});
+	if (tStringStyle) {
+		styles.push(tStringStyle);
 	}
 	//#endregion
 
@@ -384,6 +373,11 @@
 	return groupList;
 };
 
+const getDrawStyles = async () => {
+	const res = await getMapDrawStyles();
+	const styleList = res?.values ?? [];
+	olMap.value.setDrawStyles(styleList);
+};
 
 const getThemeList = async () => {
 	const res = await getMapThemeList();
@@ -406,7 +400,6 @@
 			type: 'theme',
 			activeTheme: null,
 			legends: null,
-			
 		};
 		mapGroupItem.children.push(data);
 		return preVal;
@@ -414,6 +407,7 @@
 	olMap.value.setAllThemes(themeTreeData);
 };
 const initVectorTileLayer = async () => {
+	await getDrawStyles();
 	const res = await getMapLayersByPost();
 	const layers = reverse(res?.layers ?? []);
 	if (layers.length === 0) return;
@@ -424,7 +418,6 @@
 
 		layer.set('originStyle', styleFunc);
 		layerModels.push(layer);
-	
 	}
 	getGroupList().then((groupList) => {
 		olMap.value.setAllLayers(layerModels, layers, groupList);

--
Gitblit v1.9.3