my-openlayer 2.4.8 → 2.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,156 +1,156 @@
1
- # my-openlayer
2
-
3
- my-openlayer 是一个基于 [OpenLayers](https://openlayers.org/) 的现代地图组件库,专为 Web GIS 应用开发者设计。提供完整的 TypeScript 支持、模块化的类型定义、强大的错误处理和事件管理系统,支持天地图底图加载、要素绘制、图层管理、事件监听等丰富功能,极大提升地图开发效率。
4
-
5
- [![npm version](https://img.shields.io/npm/v/my-openlayer.svg)](https://www.npmjs.com/package/my-openlayer)
6
- [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
-
9
- ---
10
-
11
- ## 项目概述
12
-
13
- - **项目名称**:`my-openlayer`
14
- - **用途**:基于 OpenLayers 的 TypeScript 地图组件库,提供点/线/面要素、底图切换、热力图、事件与配置管理等能力。
15
- - **目标用户**:Web GIS 开发者、可视化工程师、前端开发者
16
-
17
- ## 功能亮点
18
-
19
- - **🗺️ 底图管理 (MapBaseLayers)**
20
- - 支持天地图矢量、影像、地形底图切换
21
- - 动态切换底图与注记图层管理
22
- - 地图裁剪与自定义范围显示
23
- - 支持 GeoServer WMS 图层
24
-
25
- - **📍 要素操作**
26
- - **点位管理 (Point)**:点位标注(自定义图标、聚合、闪烁)
27
- - **线要素绘制 (Line)**:线要素绘制(虚线、样式自定义)
28
- - **面要素 (Polygon)**:面要素绘制、分区高亮、遮罩层
29
- - **Vue组件支持 (VueTemplatePoint)**:支持将 Vue 组件作为地图点位渲染
30
- - **河流图层 (RiverLayerManager)**:支持分级显示的河流图层管理
31
-
32
- - **🛠️ 地图工具**
33
- - **测量工具 (MeasureHandler)**:距离和面积测量
34
- - **要素选择 (SelectHandler)**:支持点击、悬停、多选等交互选择
35
- - **地图工具 (MapTools)**:图层管理、定位、视图自适应
36
- - **事件管理 (EventManager)**:统一的地图事件监听与管理
37
-
38
- - **⚡ 高级特性**
39
- - **TypeScript 完全支持**:提供完整的类型定义
40
- - **错误处理 (ErrorHandler)**:统一的错误捕获与日志
41
- - **配置管理 (ConfigManager)**:集中管理默认配置
42
- - **坐标系支持**:内置 CGCS2000 坐标系支持
43
-
44
- ## 安装
45
-
46
- ```bash
47
- npm install my-openlayer
48
- # 或
49
- yarn add my-openlayer
50
- # 或
51
- pnpm add my-openlayer
52
- ```
53
-
54
- ### 依赖要求
55
-
56
- - **Node.js**: >= 18
57
- - **OpenLayers**: ^10.6.1
58
- - **proj4**: ^2.7.5
59
- - **@turf/turf**: ^7.2.0
60
-
61
- ## 快速上手
62
-
63
- ### 1. 初始化地图
64
-
65
- ```typescript
66
- import MyOl, { MapInitType } from 'my-openlayer';
67
-
68
- const mapConfig: MapInitType = {
69
- center: [119.81, 29.969],
70
- zoom: 10,
71
- token: import.meta.env.VITE_TIANDITU_TOKEN, // 天地图 Token
72
- annotation: true
73
- };
74
-
75
- const map = new MyOl('map-container', mapConfig);
76
- ```
77
-
78
- ### 2. 使用功能模块
79
-
80
- ```typescript
81
- // 获取模块实例
82
- const point = map.getPoint();
83
- const line = map.getLine();
84
- const polygon = map.getPolygon();
85
-
86
- // 添加点位
87
- point.addPoint([{ lgtd: 119.81, lttd: 29.969, name: '示例点' }], {
88
- layerName: 'example-point',
89
- img: 'marker.png'
90
- });
91
- ```
92
-
93
- ## 文档索引
94
-
95
- 为了提供更详细的说明,我们将文档拆分为独立的模块文件:
96
-
97
- ### 核心类库
98
- - **[MyOl](docs/MyOl.md)**: 地图入口类,负责初始化和模块访问。
99
- - **[MapBaseLayers](docs/MapBaseLayers.md)**: 底图与注记管理。
100
- - **[ConfigManager](docs/ConfigManager.md)**: 配置管理。
101
- - **[EventManager](docs/EventManager.md)**: 事件管理。
102
- - **[ErrorHandler](docs/ErrorHandler.md)**: 错误处理。
103
-
104
- ### 要素操作
105
- - **[Point](docs/Point.md)**: 点要素(含聚合、DOM点位)。
106
- - **[Line](docs/Line.md)**: 线要素。
107
- - **[Polygon](docs/Polygon.md)**: 面要素(含热力图、图片层)。
108
- - **[VueTemplatePoint](docs/VueTemplatePoint.md)**: Vue 组件点位。
109
- - **[RiverLayerManager](docs/RiverLayerManager.md)**: 河流图层管理。
110
-
111
- ### 交互与工具
112
- - **[SelectHandler](docs/SelectHandler.md)**: 要素选择交互(支持独立样式渲染、多选隔离)。
113
- - **[MeasureHandler](docs/MeasureHandler.md)**: 测量工具。
114
- - **[MapTools](docs/MapTools.md)**: 通用地图工具。
115
- - **[ValidationUtils](docs/ValidationUtils.md)**: 验证工具。
116
-
117
- ## 详细用法示例
118
-
119
- ### 底图切换
120
-
121
- ```typescript
122
- const baseLayers = map.getMapBaseLayers();
123
- baseLayers.switchBaseLayer('img_c'); // 切换到影像底图
124
- ```
125
-
126
- ### 测量工具
127
-
128
- ```typescript
129
- import { MeasureHandler } from 'my-openlayer';
130
-
131
- // 需要传入原生的 OpenLayers map 实例
132
- const measure = new MeasureHandler(map.map);
133
-
134
- measure.start('LineString'); // 开始测距
135
- measure.end(); // 结束测量
136
- ```
137
-
138
- > 注意:部分高级功能(如 SelectHandler)可以通过 `map.getSelectHandler()` 访问。
139
-
140
- ## 贡献指南
141
-
142
- 欢迎提交 Issue 或 Pull Request!
143
-
144
- 1. Fork 本仓库
145
- 2. 新建分支:`git checkout -b feature/your-feature`
146
- 3. 提交更改:`git commit -m 'feat: 新功能描述'`
147
- 4. 推送分支:`git push origin feature/your-feature`
148
- 5. 提交 Pull Request
149
-
150
- ## 许可证
151
-
152
- [MIT](LICENSE)
153
-
154
- ---
155
-
156
- **联系方式**: 2364184627@qq.com | [GitHub Issues](https://github.com/cuteyuchen/my-openlayer/issues)
1
+ # my-openlayer
2
+
3
+ my-openlayer 是一个基于 [OpenLayers](https://openlayers.org/) 的现代地图组件库,专为 Web GIS 应用开发者设计。提供完整的 TypeScript 支持、模块化的类型定义、强大的错误处理和事件管理系统,支持天地图底图加载、要素绘制、图层管理、事件监听等丰富功能,极大提升地图开发效率。
4
+
5
+ [![npm version](https://img.shields.io/npm/v/my-openlayer.svg)](https://www.npmjs.com/package/my-openlayer)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ ---
10
+
11
+ ## 项目概述
12
+
13
+ - **项目名称**:`my-openlayer`
14
+ - **用途**:基于 OpenLayers 的 TypeScript 地图组件库,提供点/线/面要素、底图切换、热力图、事件与配置管理等能力。
15
+ - **目标用户**:Web GIS 开发者、可视化工程师、前端开发者
16
+
17
+ ## 功能亮点
18
+
19
+ - **🗺️ 底图管理 (MapBaseLayers)**
20
+ - 支持天地图矢量、影像、地形底图切换
21
+ - 动态切换底图与注记图层管理
22
+ - 地图裁剪与自定义范围显示
23
+ - 支持 GeoServer WMS 图层
24
+
25
+ - **📍 要素操作**
26
+ - **点位管理 (Point)**:点位标注(自定义图标、聚合、闪烁)
27
+ - **线要素绘制 (Line)**:线要素绘制(虚线、样式自定义)
28
+ - **面要素 (Polygon)**:面要素绘制、分区高亮、遮罩层
29
+ - **Vue组件支持 (VueTemplatePoint)**:支持将 Vue 组件作为地图点位渲染
30
+ - **河流图层 (RiverLayerManager)**:支持分级显示的河流图层管理
31
+
32
+ - **🛠️ 地图工具**
33
+ - **测量工具 (MeasureHandler)**:距离和面积测量
34
+ - **要素选择 (SelectHandler)**:支持点击、悬停、多选等交互选择
35
+ - **地图工具 (MapTools)**:图层管理、定位、视图自适应
36
+ - **事件管理 (EventManager)**:统一的地图事件监听与管理
37
+
38
+ - **⚡ 高级特性**
39
+ - **TypeScript 完全支持**:提供完整的类型定义
40
+ - **错误处理 (ErrorHandler)**:统一的错误捕获与日志
41
+ - **配置管理 (ConfigManager)**:集中管理默认配置
42
+ - **坐标系支持**:内置 CGCS2000 坐标系支持
43
+
44
+ ## 安装
45
+
46
+ ```bash
47
+ npm install my-openlayer
48
+ # 或
49
+ yarn add my-openlayer
50
+ # 或
51
+ pnpm add my-openlayer
52
+ ```
53
+
54
+ ### 依赖要求
55
+
56
+ - **Node.js**: >= 18
57
+ - **OpenLayers**: ^10.6.1
58
+ - **proj4**: ^2.7.5
59
+ - **@turf/turf**: ^7.2.0
60
+
61
+ ## 快速上手
62
+
63
+ ### 1. 初始化地图
64
+
65
+ ```typescript
66
+ import MyOl, { MapInitType } from 'my-openlayer';
67
+
68
+ const mapConfig: MapInitType = {
69
+ center: [119.81, 29.969],
70
+ zoom: 10,
71
+ token: import.meta.env.VITE_TIANDITU_TOKEN, // 天地图 Token
72
+ annotation: true
73
+ };
74
+
75
+ const map = new MyOl('map-container', mapConfig);
76
+ ```
77
+
78
+ ### 2. 使用功能模块
79
+
80
+ ```typescript
81
+ // 获取模块实例
82
+ const point = map.getPoint();
83
+ const line = map.getLine();
84
+ const polygon = map.getPolygon();
85
+
86
+ // 添加点位
87
+ point.addPoint([{ lgtd: 119.81, lttd: 29.969, name: '示例点' }], {
88
+ layerName: 'example-point',
89
+ img: 'marker.png'
90
+ });
91
+ ```
92
+
93
+ ## 文档索引
94
+
95
+ 为了提供更详细的说明,我们将文档拆分为独立的模块文件:
96
+
97
+ ### 核心类库
98
+ - **[MyOl](docs/MyOl.md)**: 地图入口类,负责初始化和模块访问。
99
+ - **[MapBaseLayers](docs/MapBaseLayers.md)**: 底图与注记管理。
100
+ - **[ConfigManager](docs/ConfigManager.md)**: 配置管理。
101
+ - **[EventManager](docs/EventManager.md)**: 事件管理。
102
+ - **[ErrorHandler](docs/ErrorHandler.md)**: 错误处理。
103
+
104
+ ### 要素操作
105
+ - **[Point](docs/Point.md)**: 点要素(含聚合、DOM点位)。
106
+ - **[Line](docs/Line.md)**: 线要素。
107
+ - **[Polygon](docs/Polygon.md)**: 面要素(含热力图、图片层)。
108
+ - **[VueTemplatePoint](docs/VueTemplatePoint.md)**: Vue 组件点位。
109
+ - **[RiverLayerManager](docs/RiverLayerManager.md)**: 河流图层管理。
110
+
111
+ ### 交互与工具
112
+ - **[SelectHandler](docs/SelectHandler.md)**: 要素选择交互(支持独立样式渲染、多选隔离)。
113
+ - **[MeasureHandler](docs/MeasureHandler.md)**: 测量工具。
114
+ - **[MapTools](docs/MapTools.md)**: 通用地图工具。
115
+ - **[ValidationUtils](docs/ValidationUtils.md)**: 验证工具。
116
+
117
+ ## 详细用法示例
118
+
119
+ ### 底图切换
120
+
121
+ ```typescript
122
+ const baseLayers = map.getMapBaseLayers();
123
+ baseLayers.switchBaseLayer('img_c'); // 切换到影像底图
124
+ ```
125
+
126
+ ### 测量工具
127
+
128
+ ```typescript
129
+ import { MeasureHandler } from 'my-openlayer';
130
+
131
+ // 需要传入原生的 OpenLayers map 实例
132
+ const measure = new MeasureHandler(map.map);
133
+
134
+ measure.start('LineString'); // 开始测距
135
+ measure.end(); // 结束测量
136
+ ```
137
+
138
+ > 注意:部分高级功能(如 SelectHandler)可以通过 `map.getSelectHandler()` 访问。
139
+
140
+ ## 贡献指南
141
+
142
+ 欢迎提交 Issue 或 Pull Request!
143
+
144
+ 1. Fork 本仓库
145
+ 2. 新建分支:`git checkout -b feature/your-feature`
146
+ 3. 提交更改:`git commit -m 'feat: 新功能描述'`
147
+ 4. 推送分支:`git push origin feature/your-feature`
148
+ 5. 提交 Pull Request
149
+
150
+ ## 许可证
151
+
152
+ [MIT](LICENSE)
153
+
154
+ ---
155
+
156
+ **联系方式**: 2364184627@qq.com | [GitHub Issues](https://github.com/cuteyuchen/my-openlayer/issues)
package/core/Point.js CHANGED
@@ -262,9 +262,27 @@ export default class Point {
262
262
  addDomPoint(twinkleList, callback) {
263
263
  let anchors = [];
264
264
  twinkleList.forEach(twinkleItem => {
265
- // 创建DOM元素
266
- const element = document.createElement('div');
267
- element.className = twinkleItem.className || '';
265
+ let element;
266
+ // 创建或获取DOM元素
267
+ if (twinkleItem.element) {
268
+ if (typeof twinkleItem.element === 'function') {
269
+ element = twinkleItem.element(twinkleItem);
270
+ }
271
+ else {
272
+ element = twinkleItem.element;
273
+ }
274
+ // 如果有className,追加到自定义元素
275
+ if (twinkleItem.className) {
276
+ const classes = twinkleItem.className.split(/\s+/).filter(Boolean);
277
+ if (classes.length > 0) {
278
+ element.classList.add(...classes);
279
+ }
280
+ }
281
+ }
282
+ else {
283
+ element = document.createElement('div');
284
+ element.className = twinkleItem.className || '';
285
+ }
268
286
  // 添加点击事件
269
287
  if (callback) {
270
288
  element.addEventListener('click', () => {
@@ -1,57 +1,57 @@
1
- import { defineConfig } from 'vitepress'
2
-
3
- export default defineConfig({
4
- base: '/my-openlayer/',
5
- title: "MyOpenLayer",
6
- description: "基于 OpenLayers 的现代地图组件库",
7
- lang: 'zh-CN',
8
- themeConfig: {
9
- nav: [
10
- { text: '首页', link: '/' },
11
- { text: '指南', link: '/MyOl' },
12
- { text: 'API', link: '/MyOl' },
13
- { text: 'GitHub', link: 'https://github.com/cuteyuchen/my-openlayer' }
14
- ],
15
-
16
- sidebar: [
17
- {
18
- text: '核心类库',
19
- items: [
20
- { text: 'MyOl 地图入口', link: '/MyOl' },
21
- { text: 'MapBaseLayers 底图管理', link: '/MapBaseLayers' },
22
- { text: 'ConfigManager 配置管理', link: '/ConfigManager' },
23
- { text: 'EventManager 事件管理', link: '/EventManager' },
24
- { text: 'ErrorHandler 错误处理', link: '/ErrorHandler' }
25
- ]
26
- },
27
- {
28
- text: '要素操作',
29
- items: [
30
- { text: 'Point 点要素', link: '/Point' },
31
- { text: 'Line 线要素', link: '/Line' },
32
- { text: 'Polygon 面要素', link: '/Polygon' },
33
- { text: 'VueTemplatePoint Vue点位', link: '/VueTemplatePoint' },
34
- { text: 'RiverLayerManager 河流图层', link: '/RiverLayerManager' }
35
- ]
36
- },
37
- {
38
- text: '交互与工具',
39
- items: [
40
- { text: 'SelectHandler 要素选择', link: '/SelectHandler' },
41
- { text: 'MeasureHandler 测量工具', link: '/MeasureHandler' },
42
- { text: 'MapTools 地图工具', link: '/MapTools' },
43
- { text: 'ValidationUtils 验证工具', link: '/ValidationUtils' }
44
- ]
45
- }
46
- ],
47
-
48
- socialLinks: [
49
- { icon: 'github', link: 'https://github.com/cuteyuchen/my-openlayer' }
50
- ],
51
-
52
- footer: {
53
- message: 'Released under the MIT License.',
54
- copyright: 'Copyright © 2024-present'
55
- }
56
- }
57
- })
1
+ import { defineConfig } from 'vitepress'
2
+
3
+ export default defineConfig({
4
+ base: '/my-openlayer/',
5
+ title: "MyOpenLayer",
6
+ description: "基于 OpenLayers 的现代地图组件库",
7
+ lang: 'zh-CN',
8
+ themeConfig: {
9
+ nav: [
10
+ { text: '首页', link: '/' },
11
+ { text: '指南', link: '/MyOl' },
12
+ { text: 'API', link: '/MyOl' },
13
+ { text: 'GitHub', link: 'https://github.com/cuteyuchen/my-openlayer' }
14
+ ],
15
+
16
+ sidebar: [
17
+ {
18
+ text: '核心类库',
19
+ items: [
20
+ { text: 'MyOl 地图入口', link: '/MyOl' },
21
+ { text: 'MapBaseLayers 底图管理', link: '/MapBaseLayers' },
22
+ { text: 'ConfigManager 配置管理', link: '/ConfigManager' },
23
+ { text: 'EventManager 事件管理', link: '/EventManager' },
24
+ { text: 'ErrorHandler 错误处理', link: '/ErrorHandler' }
25
+ ]
26
+ },
27
+ {
28
+ text: '要素操作',
29
+ items: [
30
+ { text: 'Point 点要素', link: '/Point' },
31
+ { text: 'Line 线要素', link: '/Line' },
32
+ { text: 'Polygon 面要素', link: '/Polygon' },
33
+ { text: 'VueTemplatePoint Vue点位', link: '/VueTemplatePoint' },
34
+ { text: 'RiverLayerManager 河流图层', link: '/RiverLayerManager' }
35
+ ]
36
+ },
37
+ {
38
+ text: '交互与工具',
39
+ items: [
40
+ { text: 'SelectHandler 要素选择', link: '/SelectHandler' },
41
+ { text: 'MeasureHandler 测量工具', link: '/MeasureHandler' },
42
+ { text: 'MapTools 地图工具', link: '/MapTools' },
43
+ { text: 'ValidationUtils 验证工具', link: '/ValidationUtils' }
44
+ ]
45
+ }
46
+ ],
47
+
48
+ socialLinks: [
49
+ { icon: 'github', link: 'https://github.com/cuteyuchen/my-openlayer' }
50
+ ],
51
+
52
+ footer: {
53
+ message: 'Released under the MIT License.',
54
+ copyright: 'Copyright © 2024-present'
55
+ }
56
+ }
57
+ })
@@ -1,71 +1,71 @@
1
- # ConfigManager 配置管理
2
-
3
- `ConfigManager` 类用于统一管理地图组件的默认配置和常量。它提供了一系列静态只读属性,确保整个应用中使用一致的配置默认值。
4
-
5
- ## 导入
6
-
7
- ```typescript
8
- import { ConfigManager } from 'my-openlayer';
9
- ```
10
-
11
- ## 静态属性
12
-
13
- `ConfigManager` 包含以下类别的默认配置:
14
-
15
- ### 点位配置 (Point Options)
16
-
17
- | 属性名 | 类型 | 描述 | 默认值 |
18
- | :--- | :--- | :--- | :--- |
19
- | `DEFAULT_POINT_OPTIONS` | `object` | 默认点位基础配置 | `{ visible: true, zIndex: 21 }` |
20
- | `DEFAULT_POINT_TEXT_OPTIONS` | `object` | 默认点位文本配置 | `{ textFont: '12px Calibri,sans-serif', textFillColor: '#FFF', textStrokeColor: '#000', textStrokeWidth: 3, textOffsetY: 20 }` |
21
- | `DEFAULT_POINT_ICON_SCALE` | `number` | 默认图标缩放比例 | `1` |
22
- | `DEFAULT_CLUSTER_OPTIONS` | `object` | 默认聚合配置 | `{ distance: 40, minDistance: 0, zIndex: 21 }` |
23
- | `DEFAULT_DOM_POINT_OVERLAY_OPTIONS` | `object` | 默认 DOM 点覆盖物配置 | `{ positioning: 'center-center', stopEvent: false }` |
24
-
25
- ### 线配置 (Line Options)
26
-
27
- | 属性名 | 类型 | 描述 | 默认值 |
28
- | :--- | :--- | :--- | :--- |
29
- | `DEFAULT_LINE_OPTIONS` | `object` | 默认线样式配置 | `{ type: 'line', strokeColor: 'rgba(3, 122, 255, 1)', strokeWidth: 2, visible: true, layerName: 'lineLayer', zIndex: 15 }` |
30
-
31
- ### 面配置 (Polygon Options)
32
-
33
- | 属性名 | 类型 | 描述 | 默认值 |
34
- | :--- | :--- | :--- | :--- |
35
- | `DEFAULT_POLYGON_OPTIONS` | `object` | 默认面样式配置 | `{ zIndex: 11, visible: true, textFont: '14px Calibri,sans-serif', textFillColor: '#FFF', textStrokeColor: '#409EFF', textStrokeWidth: 2 }` |
36
- | `DEFAULT_POLYGON_COLOR_MAP` | `object` | 默认面颜色映射 (用于分级渲染) | `{ '0': 'rgba(255, 0, 0, 0.6)', '1': 'rgba(245, 154, 35, 0.6)', ... }` |
37
-
38
- ## 使用示例
39
-
40
- ### 获取默认配置
41
-
42
- ```typescript
43
- import { ConfigManager } from 'my-openlayer';
44
-
45
- // 获取默认点位配置
46
- const pointOptions = {
47
- ...ConfigManager.DEFAULT_POINT_OPTIONS,
48
- ...ConfigManager.DEFAULT_POINT_TEXT_OPTIONS
49
- };
50
-
51
- // 获取默认线配置
52
- const lineOptions = ConfigManager.DEFAULT_LINE_OPTIONS;
53
- ```
54
-
55
- ### 在自定义组件中使用
56
-
57
- ```typescript
58
- import { ConfigManager } from 'my-openlayer';
59
-
60
- class MyComponent {
61
- private options: any;
62
-
63
- constructor(options: any) {
64
- // 合并用户配置和默认配置
65
- this.options = {
66
- ...ConfigManager.DEFAULT_POINT_OPTIONS,
67
- ...options
68
- };
69
- }
70
- }
71
- ```
1
+ # ConfigManager 配置管理
2
+
3
+ `ConfigManager` 类用于统一管理地图组件的默认配置和常量。它提供了一系列静态只读属性,确保整个应用中使用一致的配置默认值。
4
+
5
+ ## 导入
6
+
7
+ ```typescript
8
+ import { ConfigManager } from 'my-openlayer';
9
+ ```
10
+
11
+ ## 静态属性
12
+
13
+ `ConfigManager` 包含以下类别的默认配置:
14
+
15
+ ### 点位配置 (Point Options)
16
+
17
+ | 属性名 | 类型 | 描述 | 默认值 |
18
+ | :--- | :--- | :--- | :--- |
19
+ | `DEFAULT_POINT_OPTIONS` | `object` | 默认点位基础配置 | `{ visible: true, zIndex: 21 }` |
20
+ | `DEFAULT_POINT_TEXT_OPTIONS` | `object` | 默认点位文本配置 | `{ textFont: '12px Calibri,sans-serif', textFillColor: '#FFF', textStrokeColor: '#000', textStrokeWidth: 3, textOffsetY: 20 }` |
21
+ | `DEFAULT_POINT_ICON_SCALE` | `number` | 默认图标缩放比例 | `1` |
22
+ | `DEFAULT_CLUSTER_OPTIONS` | `object` | 默认聚合配置 | `{ distance: 40, minDistance: 0, zIndex: 21 }` |
23
+ | `DEFAULT_DOM_POINT_OVERLAY_OPTIONS` | `object` | 默认 DOM 点覆盖物配置 | `{ positioning: 'center-center', stopEvent: false }` |
24
+
25
+ ### 线配置 (Line Options)
26
+
27
+ | 属性名 | 类型 | 描述 | 默认值 |
28
+ | :--- | :--- | :--- | :--- |
29
+ | `DEFAULT_LINE_OPTIONS` | `object` | 默认线样式配置 | `{ type: 'line', strokeColor: 'rgba(3, 122, 255, 1)', strokeWidth: 2, visible: true, layerName: 'lineLayer', zIndex: 15 }` |
30
+
31
+ ### 面配置 (Polygon Options)
32
+
33
+ | 属性名 | 类型 | 描述 | 默认值 |
34
+ | :--- | :--- | :--- | :--- |
35
+ | `DEFAULT_POLYGON_OPTIONS` | `object` | 默认面样式配置 | `{ zIndex: 11, visible: true, textFont: '14px Calibri,sans-serif', textFillColor: '#FFF', textStrokeColor: '#409EFF', textStrokeWidth: 2 }` |
36
+ | `DEFAULT_POLYGON_COLOR_MAP` | `object` | 默认面颜色映射 (用于分级渲染) | `{ '0': 'rgba(255, 0, 0, 0.6)', '1': 'rgba(245, 154, 35, 0.6)', ... }` |
37
+
38
+ ## 使用示例
39
+
40
+ ### 获取默认配置
41
+
42
+ ```typescript
43
+ import { ConfigManager } from 'my-openlayer';
44
+
45
+ // 获取默认点位配置
46
+ const pointOptions = {
47
+ ...ConfigManager.DEFAULT_POINT_OPTIONS,
48
+ ...ConfigManager.DEFAULT_POINT_TEXT_OPTIONS
49
+ };
50
+
51
+ // 获取默认线配置
52
+ const lineOptions = ConfigManager.DEFAULT_LINE_OPTIONS;
53
+ ```
54
+
55
+ ### 在自定义组件中使用
56
+
57
+ ```typescript
58
+ import { ConfigManager } from 'my-openlayer';
59
+
60
+ class MyComponent {
61
+ private options: any;
62
+
63
+ constructor(options: any) {
64
+ // 合并用户配置和默认配置
65
+ this.options = {
66
+ ...ConfigManager.DEFAULT_POINT_OPTIONS,
67
+ ...options
68
+ };
69
+ }
70
+ }
71
+ ```