my-openlayer 2.5.5 → 3.0.2

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 (53) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/MyOl.d.ts +3 -22
  3. package/MyOl.js +10 -108
  4. package/README.md +116 -31
  5. package/core/line/Line.d.ts +19 -5
  6. package/core/line/Line.js +25 -10
  7. package/core/line/index.d.ts +0 -2
  8. package/core/line/index.js +0 -1
  9. package/core/map/ConfigManager.d.ts +137 -99
  10. package/core/map/ConfigManager.js +145 -175
  11. package/core/map/MapBaseLayers.d.ts +6 -0
  12. package/core/map/MapBaseLayers.js +9 -0
  13. package/core/map/MapTools.d.ts +16 -0
  14. package/core/map/MapTools.js +35 -1
  15. package/core/point/Point.d.ts +40 -14
  16. package/core/point/Point.js +70 -4
  17. package/core/point/PointOverlay.d.ts +2 -4
  18. package/core/point/PointOverlay.js +2 -1
  19. package/core/point/PointPulseLayer.js +6 -4
  20. package/core/polygon/Polygon.d.ts +19 -16
  21. package/core/polygon/Polygon.js +41 -63
  22. package/core/polygon/PolygonHeatmapLayer.js +15 -2
  23. package/core/polygon/PolygonMaskLayer.d.ts +2 -2
  24. package/core/polygon/PolygonMaskLayer.js +3 -1
  25. package/core/polygon/PolygonStyleFactory.d.ts +4 -3
  26. package/core/projection/ProjectionManager.d.ts +66 -0
  27. package/core/projection/ProjectionManager.js +144 -0
  28. package/core/projection/index.d.ts +2 -0
  29. package/core/projection/index.js +1 -0
  30. package/core/select/SelectHandler.d.ts +1 -1
  31. package/core/vue-template-point/VueTemplatePoint.d.ts +2 -4
  32. package/core/vue-template-point/VueTemplatePoint.js +16 -2
  33. package/docs/.vitepress/config.mts +2 -2
  34. package/docs/Line.md +4 -4
  35. package/docs/MIGRATION-3.0.md +221 -0
  36. package/docs/Point.md +24 -6
  37. package/docs/Polygon.md +14 -5
  38. package/index.d.ts +5 -4
  39. package/index.js +3 -2
  40. package/package.json +6 -3
  41. package/types/base.d.ts +4 -4
  42. package/types/common.d.ts +8 -6
  43. package/types/handle.d.ts +34 -0
  44. package/types/handle.js +1 -0
  45. package/types/index.d.ts +1 -0
  46. package/types/line.d.ts +3 -2
  47. package/types/map.d.ts +1 -1
  48. package/types/point.d.ts +11 -3
  49. package/utils/ErrorHandler.d.ts +12 -0
  50. package/utils/ErrorHandler.js +21 -0
  51. package/core/line/RiverLayerManager.d.ts +0 -93
  52. package/core/line/RiverLayerManager.js +0 -340
  53. package/docs/RiverLayerManager.md +0 -187
@@ -1,36 +1,35 @@
1
+ import type { Positioning } from "ol/Overlay";
1
2
  /**
2
- * 配置管理类
3
- * 用于统一管理默认配置和验证
3
+ * P2-1:内部默认配置存储与 setDefaults 覆盖机制。
4
+ *
5
+ * 设计要点:
6
+ * - 每组默认值都通过 getter 暴露,运行时 setDefaults 可叠加 partial 覆盖
7
+ * - 旧 callsite 直接 spread `ConfigManager.DEFAULT_X` 不需要改一行代码
8
+ * - 嵌套对象(如 flowSymbol)做深合并
4
9
  */
5
- export default class ConfigManager {
6
- /**
7
- * 默认点位配置
8
- */
9
- static readonly DEFAULT_POINT_OPTIONS: {
10
+ interface DefaultsRegistry {
11
+ POINT_OPTIONS: {
10
12
  visible: boolean;
11
13
  zIndex: number;
12
14
  };
13
- static readonly DEFAULT_POINT_TEXT_OPTIONS: {
15
+ POINT_TEXT_OPTIONS: {
14
16
  textFont: string;
15
17
  textFillColor: string;
16
18
  textStrokeColor: string;
17
19
  textStrokeWidth: number;
18
20
  textOffsetY: number;
19
21
  };
20
- static readonly DEFAULT_POINT_ICON_SCALE = 1;
21
- static readonly DEFAULT_CLUSTER_OPTIONS: {
22
+ POINT_ICON_SCALE: number;
23
+ CLUSTER_OPTIONS: {
22
24
  distance: number;
23
25
  minDistance: number;
24
26
  zIndex: number;
25
27
  };
26
- static readonly DEFAULT_DOM_POINT_OVERLAY_OPTIONS: {
27
- readonly positioning: "center-center";
28
- readonly stopEvent: false;
28
+ DOM_POINT_OVERLAY_OPTIONS: {
29
+ positioning: Positioning;
30
+ stopEvent: boolean;
29
31
  };
30
- /**
31
- * 默认线配置
32
- */
33
- static readonly DEFAULT_LINE_OPTIONS: {
32
+ LINE_OPTIONS: {
34
33
  type: string;
35
34
  strokeColor: string;
36
35
  strokeWidth: number;
@@ -38,34 +37,8 @@ export default class ConfigManager {
38
37
  layerName: string;
39
38
  zIndex: number;
40
39
  };
41
- /**
42
- * 默认流动线动画配置
43
- */
44
- static readonly DEFAULT_FLOW_LINE_OPTIONS: {
45
- readonly duration: 4000;
46
- readonly loop: true;
47
- readonly autoStart: true;
48
- readonly showBaseLine: true;
49
- readonly animationMode: "icon";
50
- readonly flowSymbol: {
51
- readonly scale: 0.8;
52
- readonly rotateWithView: true;
53
- readonly count: 1;
54
- readonly spacing: 0.15;
55
- };
56
- readonly trailEnabled: false;
57
- readonly trailLength: 0;
58
- readonly zIndex: 16;
59
- readonly type: string;
60
- readonly strokeColor: string;
61
- readonly strokeWidth: number;
62
- readonly visible: boolean;
63
- readonly layerName: string;
64
- };
65
- /**
66
- * 默认面配置
67
- */
68
- static readonly DEFAULT_POLYGON_OPTIONS: {
40
+ FLOW_LINE_OPTIONS: any;
41
+ POLYGON_OPTIONS: {
69
42
  zIndex: number;
70
43
  visible: boolean;
71
44
  textFont: string;
@@ -73,96 +46,160 @@ export default class ConfigManager {
73
46
  textStrokeColor: string;
74
47
  textStrokeWidth: number;
75
48
  };
76
- static readonly DEFAULT_POLYGON_COLOR_MAP: {
77
- '0': string;
78
- '1': string;
79
- '2': string;
80
- '3': string;
81
- };
82
- /**
83
- * 默认图片图层配置
84
- */
85
- static readonly DEFAULT_IMAGE_OPTIONS: {
49
+ POLYGON_COLOR_MAP: Record<string, string>;
50
+ IMAGE_OPTIONS: {
86
51
  opacity: number;
87
52
  visible: boolean;
88
53
  layerName: string;
89
54
  zIndex: number;
90
55
  };
91
- /**
92
- * 默认遮罩图层配置
93
- */
94
- static readonly DEFAULT_MASK_OPTIONS: {
56
+ MASK_OPTIONS: {
95
57
  fillColor: string;
96
58
  opacity: number;
97
59
  visible: boolean;
98
60
  layerName: string;
61
+ zIndex: number;
99
62
  };
100
- /**
101
- * 默认文本配置
102
- */
103
- static readonly DEFAULT_TEXT_OPTIONS: {
63
+ TEXT_OPTIONS: {
104
64
  textFont: string;
105
65
  textFillColor: string;
106
66
  textStrokeColor: string;
107
67
  textStrokeWidth: number;
108
68
  };
109
- static readonly DEFAULT_HEATMAP_OPTIONS: {
69
+ HEATMAP_OPTIONS: {
110
70
  blur: number;
111
71
  radius: number;
112
72
  zIndex: number;
113
73
  opacity: number;
114
74
  };
115
- static readonly DEFAULT_HEATMAP_VALUE_KEY = "value";
116
- static readonly TIANDITU_CONFIG: {
117
- readonly BASE_URL: "//t{0-7}.tianditu.gov.cn/DataServer";
118
- readonly PROJECTION: "EPSG:4326";
119
- readonly DEFAULT_ZINDEX: 9;
120
- readonly ANNOTATION_ZINDEX_OFFSET: 10;
75
+ HEATMAP_VALUE_KEY: string;
76
+ TIANDITU_CONFIG: {
77
+ BASE_URL: string;
78
+ PROJECTION: string;
79
+ DEFAULT_ZINDEX: number;
80
+ ANNOTATION_ZINDEX_OFFSET: number;
121
81
  };
122
- static readonly DEFAULT_MAP_LAYERS_OPTIONS: {
123
- zIndex: 9;
82
+ MAP_LAYERS_OPTIONS: {
83
+ zIndex: number;
124
84
  annotation: boolean;
125
85
  mapClip: boolean;
126
- mapClipData: undefined;
86
+ mapClipData: any;
127
87
  };
128
- static readonly DEFAULT_MYOL_OPTIONS: {
129
- layers: undefined;
88
+ MYOL_OPTIONS: {
89
+ layers: any;
130
90
  zoom: number;
131
91
  center: number[];
132
- extent: undefined;
133
- };
134
- static readonly DEFAULT_VUE_TEMPLATE_POINT_OPTIONS: {
135
- readonly positioning: "center-center";
136
- readonly stopEvent: false;
137
- readonly visible: true;
138
- readonly zIndex: 1;
139
- };
140
- static readonly DEFAULT_RIVER_LEVEL_WIDTH_MAP: {
141
- 1: number;
142
- 2: number;
143
- 3: number;
144
- 4: number;
145
- 5: number;
146
- };
147
- static readonly DEFAULT_RIVER_LAYERS_BY_ZOOM_OPTIONS: {
92
+ extent: any;
93
+ };
94
+ VUE_TEMPLATE_POINT_OPTIONS: {
95
+ positioning: Positioning;
96
+ stopEvent: boolean;
97
+ visible: boolean;
98
+ zIndex: number;
99
+ };
100
+ }
101
+ /**
102
+ * 配置管理类
103
+ * 用于统一管理默认配置和验证
104
+ *
105
+ * 运行时修改默认值:调用 ConfigManager.setDefaults('LINE_OPTIONS', { strokeWidth: 4 })
106
+ * 之后所有新创建的 Line/FlowLine 都将以此为默认。
107
+ */
108
+ export default class ConfigManager {
109
+ /** 运行时覆盖默认配置。partial 会与现有 default 做深合并,未提到的键保持原值。 */
110
+ static setDefaults<K extends keyof DefaultsRegistry>(group: K, partial: Partial<DefaultsRegistry[K]>): void;
111
+ /** 取当前运行时 default(含 setDefaults 覆盖后的结果),返回深拷贝避免被外部修改。 */
112
+ static getDefaults<K extends keyof DefaultsRegistry>(group: K): DefaultsRegistry[K];
113
+ /** 把所有 setDefaults 覆盖清掉,恢复到内置默认值。 */
114
+ static resetDefaults(group?: keyof DefaultsRegistry): void;
115
+ static get DEFAULT_POINT_OPTIONS(): {
116
+ visible: boolean;
117
+ zIndex: number;
118
+ };
119
+ static get DEFAULT_POINT_TEXT_OPTIONS(): {
120
+ textFont: string;
121
+ textFillColor: string;
122
+ textStrokeColor: string;
123
+ textStrokeWidth: number;
124
+ textOffsetY: number;
125
+ };
126
+ static get DEFAULT_POINT_ICON_SCALE(): number;
127
+ static get DEFAULT_CLUSTER_OPTIONS(): {
128
+ distance: number;
129
+ minDistance: number;
130
+ zIndex: number;
131
+ };
132
+ static get DEFAULT_DOM_POINT_OVERLAY_OPTIONS(): {
133
+ positioning: Positioning;
134
+ stopEvent: boolean;
135
+ };
136
+ static get DEFAULT_LINE_OPTIONS(): {
148
137
  type: string;
149
- levelCount: number;
150
- zoomOffset: number;
151
138
  strokeColor: string;
152
139
  strokeWidth: number;
153
140
  visible: boolean;
141
+ layerName: string;
142
+ zIndex: number;
143
+ };
144
+ static get DEFAULT_FLOW_LINE_OPTIONS(): any;
145
+ static get DEFAULT_POLYGON_OPTIONS(): {
154
146
  zIndex: number;
147
+ visible: boolean;
148
+ textFont: string;
149
+ textFillColor: string;
150
+ textStrokeColor: string;
151
+ textStrokeWidth: number;
152
+ };
153
+ static get DEFAULT_POLYGON_COLOR_MAP(): Record<string, string>;
154
+ static get DEFAULT_IMAGE_OPTIONS(): {
155
+ opacity: number;
156
+ visible: boolean;
155
157
  layerName: string;
156
- removeExisting: boolean;
158
+ zIndex: number;
157
159
  };
158
- static readonly DEFAULT_RIVER_WIDTH_BY_LEVEL_OPTIONS: {
159
- type: string;
160
+ static get DEFAULT_MASK_OPTIONS(): {
161
+ fillColor: string;
162
+ opacity: number;
163
+ visible: boolean;
160
164
  layerName: string;
161
- strokeColor: string;
162
- strokeWidth: number;
165
+ zIndex: number;
166
+ };
167
+ static get DEFAULT_TEXT_OPTIONS(): {
168
+ textFont: string;
169
+ textFillColor: string;
170
+ textStrokeColor: string;
171
+ textStrokeWidth: number;
172
+ };
173
+ static get DEFAULT_HEATMAP_OPTIONS(): {
174
+ blur: number;
175
+ radius: number;
176
+ zIndex: number;
177
+ opacity: number;
178
+ };
179
+ static get DEFAULT_HEATMAP_VALUE_KEY(): string;
180
+ static get TIANDITU_CONFIG(): {
181
+ BASE_URL: string;
182
+ PROJECTION: string;
183
+ DEFAULT_ZINDEX: number;
184
+ ANNOTATION_ZINDEX_OFFSET: number;
185
+ };
186
+ static get DEFAULT_MAP_LAYERS_OPTIONS(): {
187
+ zIndex: number;
188
+ annotation: boolean;
189
+ mapClip: boolean;
190
+ mapClipData: any;
191
+ };
192
+ static get DEFAULT_MYOL_OPTIONS(): {
193
+ layers: any;
194
+ zoom: number;
195
+ center: number[];
196
+ extent: any;
197
+ };
198
+ static get DEFAULT_VUE_TEMPLATE_POINT_OPTIONS(): {
199
+ positioning: Positioning;
200
+ stopEvent: boolean;
163
201
  visible: boolean;
164
202
  zIndex: number;
165
- removeExisting: boolean;
166
203
  };
167
204
  /**
168
205
  * 合并配置选项
@@ -184,3 +221,4 @@ export default class ConfigManager {
184
221
  */
185
222
  static deepClone<T>(obj: T): T;
186
223
  }
224
+ export {};
@@ -1,8 +1,151 @@
1
+ const BUILTIN_DEFAULTS = {
2
+ POINT_OPTIONS: { visible: true, zIndex: 21 },
3
+ POINT_TEXT_OPTIONS: {
4
+ textFont: '12px Calibri,sans-serif',
5
+ textFillColor: '#FFF',
6
+ textStrokeColor: '#000',
7
+ textStrokeWidth: 3,
8
+ textOffsetY: 20
9
+ },
10
+ POINT_ICON_SCALE: 1,
11
+ CLUSTER_OPTIONS: { distance: 40, minDistance: 0, zIndex: 21 },
12
+ DOM_POINT_OVERLAY_OPTIONS: { positioning: 'center-center', stopEvent: false },
13
+ LINE_OPTIONS: {
14
+ type: 'line',
15
+ strokeColor: 'rgba(3, 122, 255, 1)',
16
+ strokeWidth: 2,
17
+ visible: true,
18
+ layerName: 'lineLayer',
19
+ zIndex: 15
20
+ },
21
+ FLOW_LINE_OPTIONS: {
22
+ type: 'line',
23
+ strokeColor: 'rgba(3, 122, 255, 1)',
24
+ strokeWidth: 2,
25
+ visible: true,
26
+ layerName: 'lineLayer',
27
+ duration: 4000,
28
+ loop: true,
29
+ autoStart: true,
30
+ showBaseLine: true,
31
+ animationMode: 'icon',
32
+ flowSymbol: {
33
+ scale: 0.8,
34
+ rotateWithView: true,
35
+ count: 1,
36
+ spacing: 0.15
37
+ },
38
+ trailEnabled: false,
39
+ trailLength: 0,
40
+ zIndex: 16
41
+ },
42
+ POLYGON_OPTIONS: {
43
+ zIndex: 11,
44
+ visible: true,
45
+ textFont: '14px Calibri,sans-serif',
46
+ textFillColor: '#FFF',
47
+ textStrokeColor: '#409EFF',
48
+ textStrokeWidth: 2
49
+ },
50
+ POLYGON_COLOR_MAP: {
51
+ '0': 'rgba(255, 0, 0, 0.6)',
52
+ '1': 'rgba(245, 154, 35, 0.6)',
53
+ '2': 'rgba(255, 238, 0, 0.6)',
54
+ '3': 'rgba(1, 111, 255, 0.6)'
55
+ },
56
+ IMAGE_OPTIONS: { opacity: 1, visible: true, layerName: 'imageLayer', zIndex: 11 },
57
+ MASK_OPTIONS: { fillColor: 'rgba(0, 0, 0, 0.5)', opacity: 1, visible: true, layerName: 'maskLayer', zIndex: 12 },
58
+ TEXT_OPTIONS: { textFont: '14px Calibri,sans-serif', textFillColor: '#FFF', textStrokeColor: '#409EFF', textStrokeWidth: 2 },
59
+ HEATMAP_OPTIONS: { blur: 15, radius: 10, zIndex: 11, opacity: 1 },
60
+ HEATMAP_VALUE_KEY: 'value',
61
+ TIANDITU_CONFIG: {
62
+ BASE_URL: '//t{0-7}.tianditu.gov.cn/DataServer',
63
+ PROJECTION: 'EPSG:4326',
64
+ DEFAULT_ZINDEX: 9,
65
+ ANNOTATION_ZINDEX_OFFSET: 10
66
+ },
67
+ MAP_LAYERS_OPTIONS: { zIndex: 9, annotation: false, mapClip: false, mapClipData: undefined },
68
+ MYOL_OPTIONS: { layers: undefined, zoom: 10, center: [119.81, 29.969], extent: undefined },
69
+ VUE_TEMPLATE_POINT_OPTIONS: { positioning: 'center-center', stopEvent: false, visible: true, zIndex: 1 }
70
+ };
71
+ /**
72
+ * 当前生效的 defaults。运行时通过 setDefaults 修改这里的值,getter 再合并。
73
+ * 深拷贝一份避免外部意外修改 BUILTIN_DEFAULTS。
74
+ */
75
+ const currentDefaults = deepClone(BUILTIN_DEFAULTS);
76
+ function deepClone(obj) {
77
+ if (obj === null || typeof obj !== 'object')
78
+ return obj;
79
+ if (obj instanceof Date)
80
+ return new Date(obj.getTime());
81
+ if (Array.isArray(obj))
82
+ return obj.map(item => deepClone(item));
83
+ const cloned = {};
84
+ for (const k in obj) {
85
+ if (Object.prototype.hasOwnProperty.call(obj, k))
86
+ cloned[k] = deepClone(obj[k]);
87
+ }
88
+ return cloned;
89
+ }
90
+ function deepMerge(base, partial) {
91
+ const result = Array.isArray(base) ? [...base] : { ...base };
92
+ for (const k of Object.keys(partial)) {
93
+ const v = partial[k];
94
+ if (v && typeof v === 'object' && !Array.isArray(v) && !(v instanceof Date)) {
95
+ result[k] = deepMerge(result[k] ?? {}, v);
96
+ }
97
+ else {
98
+ result[k] = v;
99
+ }
100
+ }
101
+ return result;
102
+ }
1
103
  /**
2
104
  * 配置管理类
3
105
  * 用于统一管理默认配置和验证
106
+ *
107
+ * 运行时修改默认值:调用 ConfigManager.setDefaults('LINE_OPTIONS', { strokeWidth: 4 })
108
+ * 之后所有新创建的 Line/FlowLine 都将以此为默认。
4
109
  */
5
- class ConfigManager {
110
+ export default class ConfigManager {
111
+ /** 运行时覆盖默认配置。partial 会与现有 default 做深合并,未提到的键保持原值。 */
112
+ static setDefaults(group, partial) {
113
+ currentDefaults[group] = deepMerge(currentDefaults[group], partial);
114
+ }
115
+ /** 取当前运行时 default(含 setDefaults 覆盖后的结果),返回深拷贝避免被外部修改。 */
116
+ static getDefaults(group) {
117
+ return deepClone(currentDefaults[group]);
118
+ }
119
+ /** 把所有 setDefaults 覆盖清掉,恢复到内置默认值。 */
120
+ static resetDefaults(group) {
121
+ if (group) {
122
+ currentDefaults[group] = deepClone(BUILTIN_DEFAULTS[group]);
123
+ }
124
+ else {
125
+ Object.keys(BUILTIN_DEFAULTS).forEach(k => {
126
+ currentDefaults[k] = deepClone(BUILTIN_DEFAULTS[k]);
127
+ });
128
+ }
129
+ }
130
+ // ---------------- 兼容性 getter(旧 callsite 直接读字段,setDefaults 透明生效)----------------
131
+ static get DEFAULT_POINT_OPTIONS() { return currentDefaults.POINT_OPTIONS; }
132
+ static get DEFAULT_POINT_TEXT_OPTIONS() { return currentDefaults.POINT_TEXT_OPTIONS; }
133
+ static get DEFAULT_POINT_ICON_SCALE() { return currentDefaults.POINT_ICON_SCALE; }
134
+ static get DEFAULT_CLUSTER_OPTIONS() { return currentDefaults.CLUSTER_OPTIONS; }
135
+ static get DEFAULT_DOM_POINT_OVERLAY_OPTIONS() { return currentDefaults.DOM_POINT_OVERLAY_OPTIONS; }
136
+ static get DEFAULT_LINE_OPTIONS() { return currentDefaults.LINE_OPTIONS; }
137
+ static get DEFAULT_FLOW_LINE_OPTIONS() { return currentDefaults.FLOW_LINE_OPTIONS; }
138
+ static get DEFAULT_POLYGON_OPTIONS() { return currentDefaults.POLYGON_OPTIONS; }
139
+ static get DEFAULT_POLYGON_COLOR_MAP() { return currentDefaults.POLYGON_COLOR_MAP; }
140
+ static get DEFAULT_IMAGE_OPTIONS() { return currentDefaults.IMAGE_OPTIONS; }
141
+ static get DEFAULT_MASK_OPTIONS() { return currentDefaults.MASK_OPTIONS; }
142
+ static get DEFAULT_TEXT_OPTIONS() { return currentDefaults.TEXT_OPTIONS; }
143
+ static get DEFAULT_HEATMAP_OPTIONS() { return currentDefaults.HEATMAP_OPTIONS; }
144
+ static get DEFAULT_HEATMAP_VALUE_KEY() { return currentDefaults.HEATMAP_VALUE_KEY; }
145
+ static get TIANDITU_CONFIG() { return currentDefaults.TIANDITU_CONFIG; }
146
+ static get DEFAULT_MAP_LAYERS_OPTIONS() { return currentDefaults.MAP_LAYERS_OPTIONS; }
147
+ static get DEFAULT_MYOL_OPTIONS() { return currentDefaults.MYOL_OPTIONS; }
148
+ static get DEFAULT_VUE_TEMPLATE_POINT_OPTIONS() { return currentDefaults.VUE_TEMPLATE_POINT_OPTIONS; }
6
149
  /**
7
150
  * 合并配置选项
8
151
  * @param defaultOptions 默认配置
@@ -29,179 +172,6 @@ class ConfigManager {
29
172
  * @returns 克隆后的对象
30
173
  */
31
174
  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;
175
+ return deepClone(obj);
48
176
  }
49
177
  }
50
- /**
51
- * 默认点位配置
52
- */
53
- ConfigManager.DEFAULT_POINT_OPTIONS = {
54
- visible: true,
55
- zIndex: 21
56
- };
57
- ConfigManager.DEFAULT_POINT_TEXT_OPTIONS = {
58
- textFont: '12px Calibri,sans-serif',
59
- textFillColor: '#FFF',
60
- textStrokeColor: '#000',
61
- textStrokeWidth: 3,
62
- textOffsetY: 20
63
- };
64
- ConfigManager.DEFAULT_POINT_ICON_SCALE = 1;
65
- ConfigManager.DEFAULT_CLUSTER_OPTIONS = {
66
- distance: 40,
67
- minDistance: 0,
68
- zIndex: 21
69
- };
70
- ConfigManager.DEFAULT_DOM_POINT_OVERLAY_OPTIONS = {
71
- positioning: 'center-center',
72
- stopEvent: false
73
- };
74
- /**
75
- * 默认线配置
76
- */
77
- ConfigManager.DEFAULT_LINE_OPTIONS = {
78
- type: 'line',
79
- strokeColor: 'rgba(3, 122, 255, 1)',
80
- strokeWidth: 2,
81
- visible: true,
82
- layerName: 'lineLayer',
83
- zIndex: 15
84
- };
85
- /**
86
- * 默认流动线动画配置
87
- */
88
- ConfigManager.DEFAULT_FLOW_LINE_OPTIONS = {
89
- ...ConfigManager.DEFAULT_LINE_OPTIONS,
90
- duration: 4000,
91
- loop: true,
92
- autoStart: true,
93
- showBaseLine: true,
94
- animationMode: 'icon',
95
- flowSymbol: {
96
- scale: 0.8,
97
- rotateWithView: true,
98
- count: 1,
99
- spacing: 0.15
100
- },
101
- trailEnabled: false,
102
- trailLength: 0,
103
- zIndex: 16
104
- };
105
- /**
106
- * 默认面配置
107
- */
108
- ConfigManager.DEFAULT_POLYGON_OPTIONS = {
109
- zIndex: 11,
110
- visible: true,
111
- textFont: '14px Calibri,sans-serif',
112
- textFillColor: '#FFF',
113
- textStrokeColor: '#409EFF',
114
- textStrokeWidth: 2
115
- };
116
- ConfigManager.DEFAULT_POLYGON_COLOR_MAP = {
117
- '0': 'rgba(255, 0, 0, 0.6)',
118
- '1': 'rgba(245, 154, 35, 0.6)',
119
- '2': 'rgba(255, 238, 0, 0.6)',
120
- '3': 'rgba(1, 111, 255, 0.6)'
121
- };
122
- /**
123
- * 默认图片图层配置
124
- */
125
- ConfigManager.DEFAULT_IMAGE_OPTIONS = {
126
- opacity: 1,
127
- visible: true,
128
- layerName: 'imageLayer',
129
- zIndex: 11
130
- };
131
- /**
132
- * 默认遮罩图层配置
133
- */
134
- ConfigManager.DEFAULT_MASK_OPTIONS = {
135
- fillColor: 'rgba(0, 0, 0, 0.5)',
136
- opacity: 1,
137
- visible: true,
138
- layerName: 'maskLayer'
139
- };
140
- /**
141
- * 默认文本配置
142
- */
143
- ConfigManager.DEFAULT_TEXT_OPTIONS = {
144
- textFont: '14px Calibri,sans-serif',
145
- textFillColor: '#FFF',
146
- textStrokeColor: '#409EFF',
147
- textStrokeWidth: 2
148
- };
149
- ConfigManager.DEFAULT_HEATMAP_OPTIONS = {
150
- blur: 15,
151
- radius: 10,
152
- zIndex: 11,
153
- opacity: 1
154
- };
155
- ConfigManager.DEFAULT_HEATMAP_VALUE_KEY = 'value';
156
- ConfigManager.TIANDITU_CONFIG = {
157
- BASE_URL: '//t{0-7}.tianditu.gov.cn/DataServer',
158
- PROJECTION: 'EPSG:4326',
159
- DEFAULT_ZINDEX: 9,
160
- ANNOTATION_ZINDEX_OFFSET: 10
161
- };
162
- ConfigManager.DEFAULT_MAP_LAYERS_OPTIONS = {
163
- zIndex: ConfigManager.TIANDITU_CONFIG.DEFAULT_ZINDEX,
164
- annotation: false,
165
- mapClip: false,
166
- mapClipData: undefined
167
- };
168
- ConfigManager.DEFAULT_MYOL_OPTIONS = {
169
- layers: undefined,
170
- zoom: 10,
171
- center: [119.81, 29.969],
172
- extent: undefined
173
- };
174
- ConfigManager.DEFAULT_VUE_TEMPLATE_POINT_OPTIONS = {
175
- positioning: 'center-center',
176
- stopEvent: false,
177
- visible: true,
178
- zIndex: 1
179
- };
180
- ConfigManager.DEFAULT_RIVER_LEVEL_WIDTH_MAP = {
181
- 1: 2,
182
- 2: 1,
183
- 3: 0.5,
184
- 4: 0.5,
185
- 5: 0.5
186
- };
187
- ConfigManager.DEFAULT_RIVER_LAYERS_BY_ZOOM_OPTIONS = {
188
- type: 'river',
189
- levelCount: 5,
190
- zoomOffset: 8,
191
- strokeColor: 'rgb(0,113,255)',
192
- strokeWidth: 3,
193
- visible: true,
194
- zIndex: 15,
195
- layerName: 'riverLayer',
196
- removeExisting: false
197
- };
198
- ConfigManager.DEFAULT_RIVER_WIDTH_BY_LEVEL_OPTIONS = {
199
- type: 'river',
200
- layerName: 'river',
201
- strokeColor: 'rgba(3, 122, 255, 1)',
202
- strokeWidth: 2,
203
- visible: true,
204
- zIndex: 15,
205
- removeExisting: false
206
- };
207
- export default ConfigManager;
@@ -8,6 +8,7 @@ import { Tile as TileLayer } from "ol/layer";
8
8
  import { TileWMS } from "ol/source";
9
9
  import WMTSTileGrid from "ol/tilegrid/WMTS";
10
10
  import XYZ from "ol/source/XYZ";
11
+ import BaseLayer from "ol/layer/Base";
11
12
  import { MapLayersOptions, TiandituType, AnnotationLayerOptions, AnnotationType } from "../../types";
12
13
  /**
13
14
  * GeoServer图层选项接口
@@ -100,6 +101,11 @@ export default class MapBaseLayers {
100
101
  * 获取当前底图类型
101
102
  */
102
103
  getCurrentBaseLayerType(): string | null;
104
+ /**
105
+ * 获取当前可见底图对应的 BaseLayer 数组(多 layer 的底图类型会返回多个)。
106
+ * 用于 MapTools.setMapClip 等需要直接操作底图实例的场景。
107
+ */
108
+ getCurrentBaseLayers(): BaseLayer[];
103
109
  /**
104
110
  * 获取默认底图类型
105
111
  * @private
@@ -183,6 +183,15 @@ export default class MapBaseLayers {
183
183
  getCurrentBaseLayerType() {
184
184
  return this.currentBaseLayerType;
185
185
  }
186
+ /**
187
+ * 获取当前可见底图对应的 BaseLayer 数组(多 layer 的底图类型会返回多个)。
188
+ * 用于 MapTools.setMapClip 等需要直接操作底图实例的场景。
189
+ */
190
+ getCurrentBaseLayers() {
191
+ if (!this.currentBaseLayerType)
192
+ return [];
193
+ return (this.layers[this.currentBaseLayerType] ?? []);
194
+ }
186
195
  /**
187
196
  * 获取默认底图类型
188
197
  * @private