my-openlayer 2.0.0 → 2.0.1

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
@@ -6,27 +6,6 @@ my-openlayer 是一个基于 [OpenLayers](https://openlayers.org/) 的现代地
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
8
 
9
- ## 🌟 版本分支策略
10
-
11
- 本项目采用双分支策略支持不同版本的 OpenLayers:
12
-
13
- | 分支 | OpenLayers 版本 | 项目版本 | 状态 | 推荐使用场景 |
14
- |------|----------------|----------|------|-------------|
15
- | **main** | 10.6.1+ | 2.x.x | 🚀 主要开发 | 新项目、追求最新功能 |
16
- | **ol6-legacy** | 6.15.1 | 1.x.x | 🛠️ 维护支持 | 现有项目、兼容性需求 |
17
-
18
- ### 安装指南
19
-
20
- ```bash
21
- # 最新版本 (OpenLayers 10.x)
22
- npm install my-openlayer@latest
23
-
24
- # 兼容版本 (OpenLayers 6.x)
25
- npm install my-openlayer@^1.0.0
26
- ```
27
-
28
- 📖 **详细说明**: [分支策略文档](./README-BRANCHES.md) | [迁移指南](./MIGRATION-GUIDE.md)
29
-
30
9
  ---
31
10
 
32
11
  ## 目录
@@ -1,88 +1,88 @@
1
- /**
2
- * 配置管理类
3
- * 用于统一管理默认配置和验证
4
- */
5
- export declare class ConfigManager {
6
- /**
7
- * 默认点位配置
8
- */
9
- static readonly DEFAULT_POINT_OPTIONS: {
10
- strokeColor: string;
11
- strokeWidth: number;
12
- fillColor: string;
13
- opacity: number;
14
- visible: boolean;
15
- layerName: string;
16
- zIndex: number;
17
- };
18
- /**
19
- * 默认线配置
20
- */
21
- static readonly DEFAULT_LINE_OPTIONS: {
22
- strokeColor: string;
23
- strokeWidth: number;
24
- opacity: number;
25
- visible: boolean;
26
- layerName: string;
27
- zIndex: number;
28
- };
29
- /**
30
- * 默认面配置
31
- */
32
- static readonly DEFAULT_POLYGON_OPTIONS: {
33
- strokeColor: string;
34
- strokeWidth: number;
35
- fillColor: string;
36
- opacity: number;
37
- visible: boolean;
38
- layerName: string;
39
- zIndex: number;
40
- };
41
- /**
42
- * 默认图片图层配置
43
- */
44
- static readonly DEFAULT_IMAGE_OPTIONS: {
45
- opacity: number;
46
- visible: boolean;
47
- layerName: string;
48
- zIndex: number;
49
- };
50
- /**
51
- * 默认遮罩图层配置
52
- */
53
- static readonly DEFAULT_MASK_OPTIONS: {
54
- fillColor: string;
55
- opacity: number;
56
- visible: boolean;
57
- layerName: string;
58
- zIndex: number;
59
- };
60
- /**
61
- * 默认文本配置
62
- */
63
- static readonly DEFAULT_TEXT_OPTIONS: {
64
- textFont: string;
65
- textFillColor: string;
66
- textStrokeColor: string;
67
- textStrokeWidth: number;
68
- };
69
- /**
70
- * 合并配置选项
71
- * @param defaultOptions 默认配置
72
- * @param userOptions 用户配置
73
- * @returns 合并后的配置
74
- */
75
- static mergeOptions<T extends Record<string, any>>(defaultOptions: T, userOptions?: Partial<T>): T;
76
- /**
77
- * 生成唯一ID
78
- * @param prefix 前缀
79
- * @returns 唯一ID
80
- */
81
- static generateId(prefix?: string): string;
82
- /**
83
- * 深度克隆对象
84
- * @param obj 要克隆的对象
85
- * @returns 克隆后的对象
86
- */
87
- static deepClone<T>(obj: T): T;
88
- }
1
+ /**
2
+ * 配置管理类
3
+ * 用于统一管理默认配置和验证
4
+ */
5
+ export declare class ConfigManager {
6
+ /**
7
+ * 默认点位配置
8
+ */
9
+ static readonly DEFAULT_POINT_OPTIONS: {
10
+ strokeColor: string;
11
+ strokeWidth: number;
12
+ fillColor: string;
13
+ opacity: number;
14
+ visible: boolean;
15
+ layerName: string;
16
+ zIndex: number;
17
+ };
18
+ /**
19
+ * 默认线配置
20
+ */
21
+ static readonly DEFAULT_LINE_OPTIONS: {
22
+ strokeColor: string;
23
+ strokeWidth: number;
24
+ opacity: number;
25
+ visible: boolean;
26
+ layerName: string;
27
+ zIndex: number;
28
+ };
29
+ /**
30
+ * 默认面配置
31
+ */
32
+ static readonly DEFAULT_POLYGON_OPTIONS: {
33
+ strokeColor: string;
34
+ strokeWidth: number;
35
+ fillColor: string;
36
+ opacity: number;
37
+ visible: boolean;
38
+ layerName: string;
39
+ zIndex: number;
40
+ };
41
+ /**
42
+ * 默认图片图层配置
43
+ */
44
+ static readonly DEFAULT_IMAGE_OPTIONS: {
45
+ opacity: number;
46
+ visible: boolean;
47
+ layerName: string;
48
+ zIndex: number;
49
+ };
50
+ /**
51
+ * 默认遮罩图层配置
52
+ */
53
+ static readonly DEFAULT_MASK_OPTIONS: {
54
+ fillColor: string;
55
+ opacity: number;
56
+ visible: boolean;
57
+ layerName: string;
58
+ zIndex: number;
59
+ };
60
+ /**
61
+ * 默认文本配置
62
+ */
63
+ static readonly DEFAULT_TEXT_OPTIONS: {
64
+ textFont: string;
65
+ textFillColor: string;
66
+ textStrokeColor: string;
67
+ textStrokeWidth: number;
68
+ };
69
+ /**
70
+ * 合并配置选项
71
+ * @param defaultOptions 默认配置
72
+ * @param userOptions 用户配置
73
+ * @returns 合并后的配置
74
+ */
75
+ static mergeOptions<T extends Record<string, any>>(defaultOptions: T, userOptions?: Partial<T>): T;
76
+ /**
77
+ * 生成唯一ID
78
+ * @param prefix 前缀
79
+ * @returns 唯一ID
80
+ */
81
+ static generateId(prefix?: string): string;
82
+ /**
83
+ * 深度克隆对象
84
+ * @param obj 要克隆的对象
85
+ * @returns 克隆后的对象
86
+ */
87
+ static deepClone<T>(obj: T): T;
88
+ }
@@ -1,112 +1,112 @@
1
- /**
2
- * 配置管理类
3
- * 用于统一管理默认配置和验证
4
- */
5
- export class ConfigManager {
6
- /**
7
- * 合并配置选项
8
- * @param defaultOptions 默认配置
9
- * @param userOptions 用户配置
10
- * @returns 合并后的配置
11
- */
12
- static mergeOptions(defaultOptions, userOptions) {
13
- return {
14
- ...defaultOptions,
15
- ...userOptions
16
- };
17
- }
18
- /**
19
- * 生成唯一ID
20
- * @param prefix 前缀
21
- * @returns 唯一ID
22
- */
23
- static generateId(prefix = 'id') {
24
- return `${prefix}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
25
- }
26
- /**
27
- * 深度克隆对象
28
- * @param obj 要克隆的对象
29
- * @returns 克隆后的对象
30
- */
31
- static deepClone(obj) {
32
- if (obj === null || typeof obj !== 'object') {
33
- return obj;
34
- }
35
- if (obj instanceof Date) {
36
- return new Date(obj.getTime());
37
- }
38
- if (Array.isArray(obj)) {
39
- return obj.map(item => ConfigManager.deepClone(item));
40
- }
41
- const cloned = {};
42
- for (const key in obj) {
43
- if (obj.hasOwnProperty(key)) {
44
- cloned[key] = ConfigManager.deepClone(obj[key]);
45
- }
46
- }
47
- return cloned;
48
- }
49
- }
50
- /**
51
- * 默认点位配置
52
- */
53
- ConfigManager.DEFAULT_POINT_OPTIONS = {
54
- strokeColor: '#409EFF',
55
- strokeWidth: 2,
56
- fillColor: 'rgba(64, 158, 255, 0.3)',
57
- opacity: 1,
58
- visible: true,
59
- layerName: 'pointLayer',
60
- zIndex: 10
61
- };
62
- /**
63
- * 默认线配置
64
- */
65
- ConfigManager.DEFAULT_LINE_OPTIONS = {
66
- strokeColor: '#409EFF',
67
- strokeWidth: 2,
68
- opacity: 1,
69
- visible: true,
70
- layerName: 'lineLayer',
71
- zIndex: 10
72
- };
73
- /**
74
- * 默认面配置
75
- */
76
- ConfigManager.DEFAULT_POLYGON_OPTIONS = {
77
- strokeColor: '#EBEEF5',
78
- strokeWidth: 2,
79
- fillColor: 'rgba(255, 255, 255, 0.3)',
80
- opacity: 1,
81
- visible: true,
82
- layerName: 'polygonLayer',
83
- zIndex: 10
84
- };
85
- /**
86
- * 默认图片图层配置
87
- */
88
- ConfigManager.DEFAULT_IMAGE_OPTIONS = {
89
- opacity: 1,
90
- visible: true,
91
- layerName: 'imageLayer',
92
- zIndex: 11
93
- };
94
- /**
95
- * 默认遮罩图层配置
96
- */
97
- ConfigManager.DEFAULT_MASK_OPTIONS = {
98
- fillColor: 'rgba(0, 0, 0, 0.5)',
99
- opacity: 1,
100
- visible: true,
101
- layerName: 'maskLayer',
102
- zIndex: 12
103
- };
104
- /**
105
- * 默认文本配置
106
- */
107
- ConfigManager.DEFAULT_TEXT_OPTIONS = {
108
- textFont: '14px Calibri,sans-serif',
109
- textFillColor: '#FFF',
110
- textStrokeColor: '#409EFF',
111
- textStrokeWidth: 2
112
- };
1
+ /**
2
+ * 配置管理类
3
+ * 用于统一管理默认配置和验证
4
+ */
5
+ export class ConfigManager {
6
+ /**
7
+ * 合并配置选项
8
+ * @param defaultOptions 默认配置
9
+ * @param userOptions 用户配置
10
+ * @returns 合并后的配置
11
+ */
12
+ static mergeOptions(defaultOptions, userOptions) {
13
+ return {
14
+ ...defaultOptions,
15
+ ...userOptions
16
+ };
17
+ }
18
+ /**
19
+ * 生成唯一ID
20
+ * @param prefix 前缀
21
+ * @returns 唯一ID
22
+ */
23
+ static generateId(prefix = 'id') {
24
+ return `${prefix}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
25
+ }
26
+ /**
27
+ * 深度克隆对象
28
+ * @param obj 要克隆的对象
29
+ * @returns 克隆后的对象
30
+ */
31
+ static deepClone(obj) {
32
+ if (obj === null || typeof obj !== 'object') {
33
+ return obj;
34
+ }
35
+ if (obj instanceof Date) {
36
+ return new Date(obj.getTime());
37
+ }
38
+ if (Array.isArray(obj)) {
39
+ return obj.map(item => ConfigManager.deepClone(item));
40
+ }
41
+ const cloned = {};
42
+ for (const key in obj) {
43
+ if (obj.hasOwnProperty(key)) {
44
+ cloned[key] = ConfigManager.deepClone(obj[key]);
45
+ }
46
+ }
47
+ return cloned;
48
+ }
49
+ }
50
+ /**
51
+ * 默认点位配置
52
+ */
53
+ ConfigManager.DEFAULT_POINT_OPTIONS = {
54
+ strokeColor: '#409EFF',
55
+ strokeWidth: 2,
56
+ fillColor: 'rgba(64, 158, 255, 0.3)',
57
+ opacity: 1,
58
+ visible: true,
59
+ layerName: 'pointLayer',
60
+ zIndex: 10
61
+ };
62
+ /**
63
+ * 默认线配置
64
+ */
65
+ ConfigManager.DEFAULT_LINE_OPTIONS = {
66
+ strokeColor: '#409EFF',
67
+ strokeWidth: 2,
68
+ opacity: 1,
69
+ visible: true,
70
+ layerName: 'lineLayer',
71
+ zIndex: 10
72
+ };
73
+ /**
74
+ * 默认面配置
75
+ */
76
+ ConfigManager.DEFAULT_POLYGON_OPTIONS = {
77
+ strokeColor: '#EBEEF5',
78
+ strokeWidth: 2,
79
+ fillColor: 'rgba(255, 255, 255, 0.3)',
80
+ opacity: 1,
81
+ visible: true,
82
+ layerName: 'polygonLayer',
83
+ zIndex: 10
84
+ };
85
+ /**
86
+ * 默认图片图层配置
87
+ */
88
+ ConfigManager.DEFAULT_IMAGE_OPTIONS = {
89
+ opacity: 1,
90
+ visible: true,
91
+ layerName: 'imageLayer',
92
+ zIndex: 11
93
+ };
94
+ /**
95
+ * 默认遮罩图层配置
96
+ */
97
+ ConfigManager.DEFAULT_MASK_OPTIONS = {
98
+ fillColor: 'rgba(0, 0, 0, 0.5)',
99
+ opacity: 1,
100
+ visible: true,
101
+ layerName: 'maskLayer',
102
+ zIndex: 12
103
+ };
104
+ /**
105
+ * 默认文本配置
106
+ */
107
+ ConfigManager.DEFAULT_TEXT_OPTIONS = {
108
+ textFont: '14px Calibri,sans-serif',
109
+ textFillColor: '#FFF',
110
+ textStrokeColor: '#409EFF',
111
+ textStrokeWidth: 2
112
+ };