my-openlayer 2.4.7 → 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.
Files changed (37) hide show
  1. package/CHANGELOG.md +208 -101
  2. package/MyOl.js +1 -1
  3. package/README.md +156 -156
  4. package/core/Point.js +21 -3
  5. package/docs/.vitepress/cache/deps/@theme_index.js +275 -0
  6. package/docs/.vitepress/cache/deps/@theme_index.js.map +7 -0
  7. package/docs/.vitepress/cache/deps/_metadata.json +40 -0
  8. package/docs/.vitepress/cache/deps/chunk-LW4I4DCF.js +12542 -0
  9. package/docs/.vitepress/cache/deps/chunk-LW4I4DCF.js.map +7 -0
  10. package/docs/.vitepress/cache/deps/chunk-Z5QSWKN2.js +9719 -0
  11. package/docs/.vitepress/cache/deps/chunk-Z5QSWKN2.js.map +7 -0
  12. package/docs/.vitepress/cache/deps/package.json +3 -0
  13. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4505 -0
  14. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
  15. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +583 -0
  16. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
  17. package/docs/.vitepress/cache/deps/vue.js +343 -0
  18. package/docs/.vitepress/cache/deps/vue.js.map +7 -0
  19. package/docs/.vitepress/config.mts +57 -0
  20. package/docs/ConfigManager.md +71 -40
  21. package/docs/ErrorHandler.md +106 -45
  22. package/docs/EventManager.md +142 -52
  23. package/docs/Line.md +187 -52
  24. package/docs/MapBaseLayers.md +198 -48
  25. package/docs/MapTools.md +172 -48
  26. package/docs/MeasureHandler.md +87 -47
  27. package/docs/MyOl.md +247 -62
  28. package/docs/Point.md +165 -58
  29. package/docs/Polygon.md +241 -65
  30. package/docs/RiverLayerManager.md +187 -59
  31. package/docs/SelectHandler.md +147 -126
  32. package/docs/ValidationUtils.md +83 -38
  33. package/docs/VueTemplatePoint.md +214 -85
  34. package/docs/index.md +78 -0
  35. package/package.json +7 -4
  36. package/types.d.ts +2 -0
  37. package/AI_CONTEXT.md +0 -147
package/CHANGELOG.md CHANGED
@@ -1,109 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## [2.4.7] - 2026-01-30
4
-
5
- ### ✨ Features
6
-
7
- - **SelectHandler:** 重构选择交互以支持独立样式渲染和多选隔离
8
- - 重构Polygon样式处理并添加示例组件
9
- - **core:** 添加基于GeoJSON数据的地图定位功能
10
- - **core:** 添加地图定位功能并重构点位相关方法
11
- - **Point:** 添加闪烁点功能及示例
12
- - **core:** 为Polygon添加layerName选项并调整图层添加逻辑
13
- - **Point:** 添加setOneVisibleByProp方法控制点显示
14
- - **Polygon:** 优化遮罩功能支持多几何图形处理
15
- - **测量工具:** 添加测量距离和面积功能及工具栏样式
16
- - **地图:** 添加自定义投影配置支持
17
- - **日志管理:** 实现统一日志开关与级别控制
18
- - **SelectHandler:** 新增要素选择处理器模块
19
- - upgrade OpenLayers to v10.6.1 and update project to v2.0.0
20
- - update MapBaseLayers to handle optional token and improve annotation layer management
21
- - 重新添加已清理的App.vue文件,移除了所有敏感token信息
22
- - 重构Vue模板点位功能并优化事件管理
23
- - **Polygon:** 改进图像图层处理逻辑并添加更新功能
24
- - 添加验证工具类并重构现有验证逻辑
25
- - **地图工具:** 重构地图工具类并增强错误处理
26
- - 重构类型系统并增强核心功能
27
-
28
- ### 🐛 Bug Fixes
29
-
30
- - **core:** 改进Vue依赖检测逻辑并更新版本号
31
- - **VueTemplatePoint:** 修复Vue3环境下pointData的类型定义
32
- - **core:** 修正Line类中layerName属性设置错误
33
- - resolve TypeScript build error in MapBaseLayers.ts
34
-
35
- ### ⚡ Performance
36
-
37
- - **Polygon:** 优化GeoJSON解析性能,直接注入layerName
38
-
39
- ### ♻️ Refactor
40
-
41
- - **MapBaseLayers:** 重构图层管理逻辑,优化代码结构和可维护性
42
- - **ConfigManager:** 集中管理默认配置并移除无用接口
43
- - **样式处理:** 统一处理自定义样式逻辑并修复代码格式
44
- - 将nameKey重命名为textKey以提高语义清晰度
45
- - 更新依赖项并优化类型导出结构
46
- - **core:** 重构DomPoint和MapBaseLayers类,优化代码结构和功能
47
-
48
- ### 📝 Documentation
49
-
50
- - 添加详细模块文档并更新发布配置
51
- - update README with branch strategy and add migration guide
52
-
53
- ## [2.4.6] - 2026-01-30
54
-
55
- ### ✨ Features
56
-
57
- - **SelectHandler:** 重构选择交互以支持独立样式渲染和多选隔离
58
- - 重构Polygon样式处理并添加示例组件
59
- - **core:** 添加基于GeoJSON数据的地图定位功能
60
- - **core:** 添加地图定位功能并重构点位相关方法
61
- - **Point:** 添加闪烁点功能及示例
62
- - **core:** 为Polygon添加layerName选项并调整图层添加逻辑
63
- - **Point:** 添加setOneVisibleByProp方法控制点显示
64
- - **Polygon:** 优化遮罩功能支持多几何图形处理
65
- - **测量工具:** 添加测量距离和面积功能及工具栏样式
66
- - **地图:** 添加自定义投影配置支持
67
- - **日志管理:** 实现统一日志开关与级别控制
68
- - **SelectHandler:** 新增要素选择处理器模块
69
- - upgrade OpenLayers to v10.6.1 and update project to v2.0.0
70
- - update MapBaseLayers to handle optional token and improve annotation layer management
71
- - 重新添加已清理的App.vue文件,移除了所有敏感token信息
72
- - 重构Vue模板点位功能并优化事件管理
73
- - **Polygon:** 改进图像图层处理逻辑并添加更新功能
74
- - 添加验证工具类并重构现有验证逻辑
75
- - **地图工具:** 重构地图工具类并增强错误处理
76
- - 重构类型系统并增强核心功能
77
-
78
- ### 🐛 Bug Fixes
79
-
80
- - **core:** 改进Vue依赖检测逻辑并更新版本号
81
- - **VueTemplatePoint:** 修复Vue3环境下pointData的类型定义
82
- - **core:** 修正Line类中layerName属性设置错误
83
- - resolve TypeScript build error in MapBaseLayers.ts
84
-
85
- ### ⚡ Performance
86
-
87
- - **Polygon:** 优化GeoJSON解析性能,直接注入layerName
88
-
89
- ### ♻️ Refactor
90
-
91
- - **MapBaseLayers:** 重构图层管理逻辑,优化代码结构和可维护性
92
- - **ConfigManager:** 集中管理默认配置并移除无用接口
93
- - **样式处理:** 统一处理自定义样式逻辑并修复代码格式
94
- - 将nameKey重命名为textKey以提高语义清晰度
95
- - 更新依赖项并优化类型导出结构
96
- - **core:** 重构DomPoint和MapBaseLayers类,优化代码结构和功能
97
-
98
- ### 📝 Documentation
99
-
100
- - 添加详细模块文档并更新发布配置
101
- - update README with branch strategy and add migration guide
102
-
103
- ## [2.4.5] - 2026-01-30
3
+ ## [2.4.9] - 2026-03-05
104
4
 
105
5
  ### ✨ Features
106
6
 
7
+ - **TwinkleItem:** 支持自定义闪烁点DOM元素
107
8
  - **SelectHandler:** 重构选择交互以支持独立样式渲染和多选隔离
108
9
  - 重构Polygon样式处理并添加示例组件
109
10
  - **core:** 添加基于GeoJSON数据的地图定位功能
@@ -147,11 +48,217 @@
147
48
 
148
49
  ### 📝 Documentation
149
50
 
51
+ - 更新技能文档的名称与描述
52
+ - 添加技能文档系统并更新项目文档结构
53
+ - add vitepress documentation and github actions workflow
150
54
  - 添加详细模块文档并更新发布配置
151
55
  - update README with branch strategy and add migration guide
152
56
 
153
57
  # Changelog
154
58
 
59
+ ## [2.4.8] - 2026-01-30
60
+
61
+ ### ✨ Features
62
+
63
+ - **SelectHandler:** 重构选择交互以支持独立样式渲染和多选隔离
64
+ - 重构Polygon样式处理并添加示例组件
65
+ - **core:** 添加基于GeoJSON数据的地图定位功能
66
+ - **core:** 添加地图定位功能并重构点位相关方法
67
+ - **Point:** 添加闪烁点功能及示例
68
+ - **core:** 为Polygon添加layerName选项并调整图层添加逻辑
69
+ - **Point:** 添加setOneVisibleByProp方法控制点显示
70
+ - **Polygon:** 优化遮罩功能支持多几何图形处理
71
+ - **测量工具:** 添加测量距离和面积功能及工具栏样式
72
+ - **地图:** 添加自定义投影配置支持
73
+ - **日志管理:** 实现统一日志开关与级别控制
74
+ - **SelectHandler:** 新增要素选择处理器模块
75
+ - upgrade OpenLayers to v10.6.1 and update project to v2.0.0
76
+ - update MapBaseLayers to handle optional token and improve annotation layer management
77
+ - 重新添加已清理的App.vue文件,移除了所有敏感token信息
78
+ - 重构Vue模板点位功能并优化事件管理
79
+ - **Polygon:** 改进图像图层处理逻辑并添加更新功能
80
+ - 添加验证工具类并重构现有验证逻辑
81
+ - **地图工具:** 重构地图工具类并增强错误处理
82
+ - 重构类型系统并增强核心功能
83
+
84
+ ### 🐛 Bug Fixes
85
+
86
+ - **core:** 改进Vue依赖检测逻辑并更新版本号
87
+ - **VueTemplatePoint:** 修复Vue3环境下pointData的类型定义
88
+ - **core:** 修正Line类中layerName属性设置错误
89
+ - resolve TypeScript build error in MapBaseLayers.ts
90
+
91
+ ### ⚡ Performance
92
+
93
+ - **Polygon:** 优化GeoJSON解析性能,直接注入layerName
94
+
95
+ ### ♻️ Refactor
96
+
97
+ - **MapBaseLayers:** 重构图层管理逻辑,优化代码结构和可维护性
98
+ - **ConfigManager:** 集中管理默认配置并移除无用接口
99
+ - **样式处理:** 统一处理自定义样式逻辑并修复代码格式
100
+ - 将nameKey重命名为textKey以提高语义清晰度
101
+ - 更新依赖项并优化类型导出结构
102
+ - **core:** 重构DomPoint和MapBaseLayers类,优化代码结构和功能
103
+
104
+ ### 📝 Documentation
105
+
106
+ - add vitepress documentation and github actions workflow
107
+ - 添加详细模块文档并更新发布配置
108
+ - update README with branch strategy and add migration guide
109
+
110
+ ## [2.4.7] - 2026-01-30
111
+
112
+ ### ✨ Features
113
+
114
+ - **SelectHandler:** 重构选择交互以支持独立样式渲染和多选隔离
115
+ - 重构Polygon样式处理并添加示例组件
116
+ - **core:** 添加基于GeoJSON数据的地图定位功能
117
+ - **core:** 添加地图定位功能并重构点位相关方法
118
+ - **Point:** 添加闪烁点功能及示例
119
+ - **core:** 为Polygon添加layerName选项并调整图层添加逻辑
120
+ - **Point:** 添加setOneVisibleByProp方法控制点显示
121
+ - **Polygon:** 优化遮罩功能支持多几何图形处理
122
+ - **测量工具:** 添加测量距离和面积功能及工具栏样式
123
+ - **地图:** 添加自定义投影配置支持
124
+ - **日志管理:** 实现统一日志开关与级别控制
125
+ - **SelectHandler:** 新增要素选择处理器模块
126
+ - upgrade OpenLayers to v10.6.1 and update project to v2.0.0
127
+ - update MapBaseLayers to handle optional token and improve annotation layer management
128
+ - 重新添加已清理的App.vue文件,移除了所有敏感token信息
129
+ - 重构Vue模板点位功能并优化事件管理
130
+ - **Polygon:** 改进图像图层处理逻辑并添加更新功能
131
+ - 添加验证工具类并重构现有验证逻辑
132
+ - **地图工具:** 重构地图工具类并增强错误处理
133
+ - 重构类型系统并增强核心功能
134
+
135
+ ### 🐛 Bug Fixes
136
+
137
+ - **core:** 改进Vue依赖检测逻辑并更新版本号
138
+ - **VueTemplatePoint:** 修复Vue3环境下pointData的类型定义
139
+ - **core:** 修正Line类中layerName属性设置错误
140
+ - resolve TypeScript build error in MapBaseLayers.ts
141
+
142
+ ### ⚡ Performance
143
+
144
+ - **Polygon:** 优化GeoJSON解析性能,直接注入layerName
145
+
146
+ ### ♻️ Refactor
147
+
148
+ - **MapBaseLayers:** 重构图层管理逻辑,优化代码结构和可维护性
149
+ - **ConfigManager:** 集中管理默认配置并移除无用接口
150
+ - **样式处理:** 统一处理自定义样式逻辑并修复代码格式
151
+ - 将nameKey重命名为textKey以提高语义清晰度
152
+ - 更新依赖项并优化类型导出结构
153
+ - **core:** 重构DomPoint和MapBaseLayers类,优化代码结构和功能
154
+
155
+ ### 📝 Documentation
156
+
157
+ - 添加详细模块文档并更新发布配置
158
+ - update README with branch strategy and add migration guide
159
+
160
+ ## [2.4.6] - 2026-01-30
161
+
162
+ ### ✨ Features
163
+
164
+ - **SelectHandler:** 重构选择交互以支持独立样式渲染和多选隔离
165
+ - 重构Polygon样式处理并添加示例组件
166
+ - **core:** 添加基于GeoJSON数据的地图定位功能
167
+ - **core:** 添加地图定位功能并重构点位相关方法
168
+ - **Point:** 添加闪烁点功能及示例
169
+ - **core:** 为Polygon添加layerName选项并调整图层添加逻辑
170
+ - **Point:** 添加setOneVisibleByProp方法控制点显示
171
+ - **Polygon:** 优化遮罩功能支持多几何图形处理
172
+ - **测量工具:** 添加测量距离和面积功能及工具栏样式
173
+ - **地图:** 添加自定义投影配置支持
174
+ - **日志管理:** 实现统一日志开关与级别控制
175
+ - **SelectHandler:** 新增要素选择处理器模块
176
+ - upgrade OpenLayers to v10.6.1 and update project to v2.0.0
177
+ - update MapBaseLayers to handle optional token and improve annotation layer management
178
+ - 重新添加已清理的App.vue文件,移除了所有敏感token信息
179
+ - 重构Vue模板点位功能并优化事件管理
180
+ - **Polygon:** 改进图像图层处理逻辑并添加更新功能
181
+ - 添加验证工具类并重构现有验证逻辑
182
+ - **地图工具:** 重构地图工具类并增强错误处理
183
+ - 重构类型系统并增强核心功能
184
+
185
+ ### 🐛 Bug Fixes
186
+
187
+ - **core:** 改进Vue依赖检测逻辑并更新版本号
188
+ - **VueTemplatePoint:** 修复Vue3环境下pointData的类型定义
189
+ - **core:** 修正Line类中layerName属性设置错误
190
+ - resolve TypeScript build error in MapBaseLayers.ts
191
+
192
+ ### ⚡ Performance
193
+
194
+ - **Polygon:** 优化GeoJSON解析性能,直接注入layerName
195
+
196
+ ### ♻️ Refactor
197
+
198
+ - **MapBaseLayers:** 重构图层管理逻辑,优化代码结构和可维护性
199
+ - **ConfigManager:** 集中管理默认配置并移除无用接口
200
+ - **样式处理:** 统一处理自定义样式逻辑并修复代码格式
201
+ - 将nameKey重命名为textKey以提高语义清晰度
202
+ - 更新依赖项并优化类型导出结构
203
+ - **core:** 重构DomPoint和MapBaseLayers类,优化代码结构和功能
204
+
205
+ ### 📝 Documentation
206
+
207
+ - 添加详细模块文档并更新发布配置
208
+ - update README with branch strategy and add migration guide
209
+
210
+ ## [2.4.5] - 2026-01-30
211
+
212
+ ### ✨ Features
213
+
214
+ - **SelectHandler:** 重构选择交互以支持独立样式渲染和多选隔离
215
+ - 重构Polygon样式处理并添加示例组件
216
+ - **core:** 添加基于GeoJSON数据的地图定位功能
217
+ - **core:** 添加地图定位功能并重构点位相关方法
218
+ - **Point:** 添加闪烁点功能及示例
219
+ - **core:** 为Polygon添加layerName选项并调整图层添加逻辑
220
+ - **Point:** 添加setOneVisibleByProp方法控制点显示
221
+ - **Polygon:** 优化遮罩功能支持多几何图形处理
222
+ - **测量工具:** 添加测量距离和面积功能及工具栏样式
223
+ - **地图:** 添加自定义投影配置支持
224
+ - **日志管理:** 实现统一日志开关与级别控制
225
+ - **SelectHandler:** 新增要素选择处理器模块
226
+ - upgrade OpenLayers to v10.6.1 and update project to v2.0.0
227
+ - update MapBaseLayers to handle optional token and improve annotation layer management
228
+ - 重新添加已清理的App.vue文件,移除了所有敏感token信息
229
+ - 重构Vue模板点位功能并优化事件管理
230
+ - **Polygon:** 改进图像图层处理逻辑并添加更新功能
231
+ - 添加验证工具类并重构现有验证逻辑
232
+ - **地图工具:** 重构地图工具类并增强错误处理
233
+ - 重构类型系统并增强核心功能
234
+
235
+ ### 🐛 Bug Fixes
236
+
237
+ - **core:** 改进Vue依赖检测逻辑并更新版本号
238
+ - **VueTemplatePoint:** 修复Vue3环境下pointData的类型定义
239
+ - **core:** 修正Line类中layerName属性设置错误
240
+ - resolve TypeScript build error in MapBaseLayers.ts
241
+
242
+ ### ⚡ Performance
243
+
244
+ - **Polygon:** 优化GeoJSON解析性能,直接注入layerName
245
+
246
+ ### ♻️ Refactor
247
+
248
+ - **MapBaseLayers:** 重构图层管理逻辑,优化代码结构和可维护性
249
+ - **ConfigManager:** 集中管理默认配置并移除无用接口
250
+ - **样式处理:** 统一处理自定义样式逻辑并修复代码格式
251
+ - 将nameKey重命名为textKey以提高语义清晰度
252
+ - 更新依赖项并优化类型导出结构
253
+ - **core:** 重构DomPoint和MapBaseLayers类,优化代码结构和功能
254
+
255
+ ### 📝 Documentation
256
+
257
+ - 添加详细模块文档并更新发布配置
258
+ - update README with branch strategy and add migration guide
259
+
260
+ # Changelog
261
+
155
262
  ## [2.4.3] - 2026-01-27
156
263
 
157
264
  ### ✨ Features
package/MyOl.js CHANGED
@@ -333,7 +333,7 @@ class MyOl {
333
333
  if (latitude < -90 || latitude > 90) {
334
334
  throw new Error('纬度值必须在 -90 到 90 之间');
335
335
  }
336
- this.getPoint().locationAction(longitude, latitude, zoom, duration);
336
+ this.getTools().locationAction(longitude, latitude, zoom, duration);
337
337
  // 记录定位操作
338
338
  this.errorHandler.debug('地图定位完成', {
339
339
  longitude,
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', () => {