From 4c20089472b20319746649decbce3a11f16cb6a0 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期五, 07 二月 2025 18:43:24 +0800
Subject: [PATCH] 切换主题,自身设置颜色、大小

---
 src/model/map/OLMap.ts |   42 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/src/model/map/OLMap.ts b/src/model/map/OLMap.ts
index 658770d..648fc18 100644
--- a/src/model/map/OLMap.ts
+++ b/src/model/map/OLMap.ts
@@ -9,10 +9,19 @@
 import WMTS from 'ol/source/WMTS';
 import WMTSTileGrid from 'ol/tilegrid/WMTS';
 import type { ViewOptions } from 'ol/View';
-
+import MVT from 'ol/format/MVT.js';
+import VectorTileLayer from 'ol/layer/VectorTile';
+import VectorTileSource from 'ol/source/VectorTile';
+import { defaults as olDefaults } from 'ol/interaction';
 import type { Ref } from 'vue';
 import { ref } from 'vue';
 import { MarkerOverlay } from './overlay/marker';
+import { TileGrid } from 'ol/tilegrid';
+import Style from 'ol/style/Style';
+import Fill from 'ol/style/Fill';
+import Stroke from 'ol/style/Stroke';
+import Circle from 'ol/style/Circle';
+
 export type LangType = 'zh_cn' | 'en';
 export const enum GaoDeSourceType {
 	/** @description 榛樿鍦板浘 */
@@ -57,10 +66,16 @@
 
 	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[]>;
+
 	activeSourceType: Ref<GaoDeSourceType> = ref(GaoDeSourceType.Vector);
 	markerIsVisible: Ref<boolean> = ref(true);
 	private emit(eventName: OLEventType, ...args: any[]) {
@@ -117,6 +132,7 @@
 			target: container, // 缁戝畾 DOM 瀹瑰櫒
 			layers: [layer], // 娣诲姞鍥惧眰
 			view: new View(view),
+			interactions: olDefaults({ doubleClickZoom: false }),
 		});
 		this.activeSourceType.value = sourceType;
 		this.markerIsVisible.value = markerIsVisible;
@@ -300,6 +316,30 @@
 		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;
+	}
+
 	getWMTS = () => {
 		const projection = getProjection('EPSG:3857');
 		const projectionExtent = projection.getExtent();

--
Gitblit v1.9.3