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