my-openlayer 0.1.18 → 1.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/dist/MyOl.d.ts CHANGED
@@ -5,63 +5,131 @@ import Point from "./core/Point";
5
5
  import Line from "./core/Line";
6
6
  import MapBaseLayers from "./core/MapBaseLayers";
7
7
  import MapTools from "./core/MapTools";
8
+ import { ErrorHandler } from './utils/ErrorHandler';
9
+ import { EventManager } from './core/EventManager';
10
+ import { ConfigManager } from './core/ConfigManager';
8
11
  import { MapInitType, EventType } from './types';
12
+ /**
13
+ * MyOl 地图核心类
14
+ * 提供完整的地图操作功能,包括点、线、面要素管理,底图切换,工具操作等
15
+ */
9
16
  export default class MyOl {
10
- map: Map;
11
- private baseLayers;
12
- private polygon;
13
- private mapTools;
14
- private point;
15
- private line;
17
+ readonly map: Map;
18
+ private _baseLayers?;
19
+ private _polygon?;
20
+ private _mapTools?;
21
+ private _point?;
22
+ private _line?;
23
+ private readonly errorHandler;
24
+ private readonly eventManager;
25
+ private readonly configManager;
16
26
  private readonly options;
17
- static DefaultOptions: MapInitType;
18
- constructor(id: string, options: MapInitType);
27
+ static readonly DefaultOptions: MapInitType;
28
+ private static readonly PROJECTIONS;
19
29
  /**
20
- * 获取视图
30
+ * 构造函数
31
+ * @param id 地图容器 DOM 元素 ID
32
+ * @param options 地图初始化配置
33
+ */
34
+ constructor(id: string, options?: Partial<MapInitType>);
35
+ /**
36
+ * 验证构造函数参数
37
+ * @private
38
+ */
39
+ private validateConstructorParams;
40
+ /**
41
+ * 初始化坐标系
42
+ * @private
43
+ */
44
+ private static initializeProjections;
45
+ /**
46
+ * 创建地图控件
47
+ * @private
48
+ */
49
+ private createControls;
50
+ /**
51
+ * 初始化事件监听
52
+ * @private
53
+ */
54
+ private initializeEventListeners;
55
+ /**
56
+ * 创建地图视图
21
57
  * @param options 视图配置
22
- * @param options.center 中心点
23
- * @param options.zoom 缩放级别
24
- * @param options.minZoom 最小缩放级别
25
- * @param options.maxZoom 最大缩放级别
26
- * @param options.extent 视图范围
27
- * @returns View
58
+ * @returns View 地图视图实例
59
+ */
60
+ static createView(options?: MapInitType): View;
61
+ /**
62
+ * 获取视图(向后兼容)
63
+ * @deprecated 请使用 createView 方法
28
64
  */
29
65
  static getView(options?: MapInitType): View;
30
66
  /**
31
- * 获取 地图 面 操作
32
- * @returns Polygon
67
+ * 获取面要素操作模块
68
+ * @returns Polygon 面要素操作实例
33
69
  */
34
70
  getPolygon(): Polygon;
71
+ /**
72
+ * 获取底图图层管理模块
73
+ * @returns MapBaseLayers 底图管理实例
74
+ */
35
75
  getMapBaseLayers(): MapBaseLayers;
36
76
  /**
37
- * 获取 地图 点 操作
38
- * @returns Point
77
+ * 获取点要素操作模块
78
+ * @returns Point 点要素操作实例
39
79
  */
40
80
  getPoint(): Point;
41
81
  /**
42
- * 获取 地图 线 操作
43
- * @returns Line
82
+ * 获取线要素操作模块
83
+ * @returns Line 线要素操作实例
44
84
  */
45
85
  getLine(): Line;
46
86
  /**
47
- * 获取 地图 工具 操作
48
- * @returns MapTools
87
+ * 获取地图工具模块
88
+ * @returns MapTools 地图工具实例
49
89
  */
50
90
  getTools(): MapTools;
91
+ /**
92
+ * 重置地图位置到初始中心点
93
+ * @param duration 动画持续时间(毫秒)
94
+ */
51
95
  resetPosition(duration?: number): void;
52
96
  /**
53
- * 地图定位
54
- * @param lgtd 经度
55
- * @param lttd 纬度
97
+ * 地图定位到指定坐标
98
+ * @param longitude 经度
99
+ * @param latitude 纬度
56
100
  * @param zoom 缩放级别
57
- * @param duration 动画时间
101
+ * @param duration 动画持续时间(毫秒)
58
102
  */
59
- locationAction(lgtd: number, lttd: number, zoom?: number, duration?: number): void;
103
+ locationAction(longitude: number, latitude: number, zoom?: number, duration?: number): void;
60
104
  /**
61
- * 地图监听事件
105
+ * 监听地图事件
62
106
  * @param eventType 事件类型
63
- * @param clickType 点击类型
64
107
  * @param callback 回调函数
108
+ * @param clickType 点击类型(可选)
109
+ */
110
+ mapOnEvent(eventType: EventType, callback: (feature?: any, e?: any) => void, clickType?: 'point' | 'line' | 'polygon'): void;
111
+ /**
112
+ * 获取错误处理器实例
113
+ * @returns ErrorHandler 错误处理器
114
+ */
115
+ getErrorHandler(): ErrorHandler;
116
+ /**
117
+ * 获取事件管理器实例
118
+ * @returns EventManager 事件管理器
119
+ */
120
+ getEventManager(): EventManager;
121
+ /**
122
+ * 获取配置管理器实例
123
+ * @returns ConfigManager 配置管理器
124
+ */
125
+ getConfigManager(): ConfigManager;
126
+ /**
127
+ * 获取当前地图配置
128
+ * @returns MapInitType 地图配置
129
+ */
130
+ getMapOptions(): Readonly<MapInitType>;
131
+ /**
132
+ * 销毁地图实例和相关资源
65
133
  */
66
- mapOnEvent(eventType: EventType, callback: (feature?: any, e?: any) => void, clickType?: 'point' | 'line' | 'polygon' | undefined): void;
134
+ destroy(): void;
67
135
  }
package/dist/MyOl.js CHANGED
@@ -1,159 +1,386 @@
1
1
  "use strict";
2
+ // OpenLayers 核心导入
2
3
  import { register as olProj4Register } from 'ol/proj/proj4';
3
4
  import { Projection as olProjProjection, addProjection as olProjAddProjection, fromLonLat as olProjFromLonLat } from 'ol/proj';
4
5
  import View from "ol/View";
5
6
  import Map from "ol/Map";
7
+ import { defaults as defaultControls } from 'ol/control';
8
+ import proj4 from "proj4";
9
+ // 内部模块导入
6
10
  import Polygon from "./core/Polygon";
7
11
  import Point from "./core/Point";
8
12
  import Line from "./core/Line";
9
13
  import MapBaseLayers from "./core/MapBaseLayers";
10
- import proj4 from "proj4";
11
14
  import MapTools from "./core/MapTools";
12
- import { defaults as defaultControls } from 'ol/control';
13
- // import { Pixel } from "ol/pixel";
14
- // import { FeatureLike } from "ol/Feature";
15
- // import { MapBrowserEvent } from "ol";
15
+ import { ErrorHandler, MyOpenLayersError, ErrorType } from './utils/ErrorHandler';
16
+ import { EventManager } from './core/EventManager';
17
+ import { ConfigManager } from './core/ConfigManager';
18
+ /**
19
+ * MyOl 地图核心类
20
+ * 提供完整的地图操作功能,包括点、线、面要素管理,底图切换,工具操作等
21
+ */
16
22
  class MyOl {
23
+ /**
24
+ * 构造函数
25
+ * @param id 地图容器 DOM 元素 ID
26
+ * @param options 地图初始化配置
27
+ */
17
28
  constructor(id, options) {
18
- options.center = options.center || MyOl.DefaultOptions.center;
19
- this.options = { ...MyOl.DefaultOptions, ...options };
20
- let layers = [];
21
- if (Array.isArray(options.layers)) {
22
- layers = options.layers;
23
- }
24
- this.map = new Map({
25
- target: id, // 地图容器
26
- view: MyOl.getView(this.options), // 视图
27
- layers: layers,
28
- controls: defaultControls({
29
- zoom: false,
30
- rotate: false,
31
- attribution: false
32
- }).extend([])
33
- });
29
+ // 初始化错误处理器(必须最先初始化)
30
+ this.errorHandler = ErrorHandler.getInstance();
31
+ try {
32
+ // 初始化配置管理器
33
+ this.configManager = new ConfigManager();
34
+ // 合并配置(处理 undefined 情况)
35
+ this.options = ConfigManager.mergeOptions(MyOl.DefaultOptions, options || {});
36
+ // 参数验证
37
+ this.validateConstructorParams(id, this.options);
38
+ // 初始化坐标系
39
+ MyOl.initializeProjections();
40
+ // 准备图层
41
+ const layers = Array.isArray(this.options.layers) ? this.options.layers : [];
42
+ // 创建地图实例
43
+ this.map = new Map({
44
+ target: id,
45
+ view: MyOl.createView(this.options),
46
+ layers: layers,
47
+ controls: this.createControls()
48
+ });
49
+ // 初始化事件管理器(需要地图实例)
50
+ this.eventManager = new EventManager(this.map);
51
+ // 初始化事件监听
52
+ this.initializeEventListeners();
53
+ }
54
+ catch (error) {
55
+ this.errorHandler.handleError(new MyOpenLayersError(`地图初始化失败: ${error instanceof Error ? error.message : '未知错误'}`, ErrorType.MAP_ERROR, { id, options }));
56
+ throw error;
57
+ }
34
58
  }
35
59
  /**
36
- * 获取视图
37
- * @param options 视图配置
38
- * @param options.center 中心点
39
- * @param options.zoom 缩放级别
40
- * @param options.minZoom 最小缩放级别
41
- * @param options.maxZoom 最大缩放级别
42
- * @param options.extent 视图范围
43
- * @returns View
60
+ * 验证构造函数参数
61
+ * @private
44
62
  */
45
- static getView(options = MyOl.DefaultOptions) {
46
- proj4.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs");
47
- proj4.defs("EPSG:4549", "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
63
+ validateConstructorParams(id, options) {
64
+ if (!id || typeof id !== 'string') {
65
+ throw new Error('地图容器 ID 必须是非空字符串');
66
+ }
67
+ if (!options || typeof options !== 'object') {
68
+ throw new Error('地图配置选项不能为空');
69
+ }
70
+ // 检查 DOM 元素是否存在
71
+ const element = document.getElementById(id);
72
+ if (!element) {
73
+ throw new Error(`找不到 ID 为 '${id}' 的 DOM 元素`);
74
+ }
75
+ }
76
+ /**
77
+ * 初始化坐标系
78
+ * @private
79
+ */
80
+ static initializeProjections() {
81
+ // 定义 CGCS2000 坐标系
82
+ proj4.defs(MyOl.PROJECTIONS.CGCS2000, "+proj=longlat +ellps=GRS80 +no_defs");
83
+ proj4.defs(MyOl.PROJECTIONS.CGCS2000_3_DEGREE, "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
84
+ // 注册到 OpenLayers
48
85
  olProj4Register(proj4);
86
+ // 添加 CGCS2000 投影
49
87
  const cgsc2000 = new olProjProjection({
50
- code: "EPSG:4490",
88
+ code: MyOl.PROJECTIONS.CGCS2000,
51
89
  extent: [-180, -90, 180, 90],
52
90
  worldExtent: [-180, -90, 180, 90],
53
91
  units: "degrees"
54
92
  });
55
93
  olProjAddProjection(cgsc2000);
56
- // 视图配置
57
- const viewOptions = {
58
- projection: cgsc2000, // 坐标系
59
- center: olProjFromLonLat(options.center, cgsc2000), // 中心点
60
- zoom: options.zoom || 10, // 缩放级别
61
- minZoom: options.minZoom || 8,
62
- maxZoom: options.maxZoom || 20
63
- };
64
- if (options.extent)
65
- viewOptions.extent = options.extent;
66
- return new View(viewOptions);
67
- }
68
- // ╔══════════╗
69
- // ║ 地图 面 ║
70
- // ╚══════════╝
71
- /**
72
- * 获取 地图 面 操作
73
- * @returns Polygon
94
+ }
95
+ /**
96
+ * 创建地图控件
97
+ * @private
98
+ */
99
+ createControls() {
100
+ return defaultControls({
101
+ zoom: false,
102
+ rotate: false,
103
+ attribution: false
104
+ }).extend([]);
105
+ }
106
+ /**
107
+ * 初始化事件监听
108
+ * @private
109
+ */
110
+ initializeEventListeners() {
111
+ // 地图加载完成事件
112
+ this.map.once('rendercomplete', () => {
113
+ console.debug('地图初始化完成', { map: this.map });
114
+ });
115
+ // 地图错误事件
116
+ this.map.on('error', (error) => {
117
+ this.errorHandler.handleError(new MyOpenLayersError('地图渲染错误', ErrorType.MAP_ERROR, { error }));
118
+ });
119
+ }
120
+ /**
121
+ * 创建地图视图
122
+ * @param options 视图配置
123
+ * @returns View 地图视图实例
124
+ */
125
+ static createView(options = MyOl.DefaultOptions) {
126
+ try {
127
+ const projection = new olProjProjection({
128
+ code: MyOl.PROJECTIONS.CGCS2000,
129
+ extent: [-180, -90, 180, 90],
130
+ worldExtent: [-180, -90, 180, 90],
131
+ units: "degrees"
132
+ });
133
+ const viewOptions = {
134
+ projection,
135
+ center: olProjFromLonLat(options.center, projection),
136
+ zoom: options.zoom ?? MyOl.DefaultOptions.zoom,
137
+ minZoom: options.minZoom ?? MyOl.DefaultOptions.minZoom,
138
+ maxZoom: options.maxZoom ?? MyOl.DefaultOptions.maxZoom,
139
+ ...(options.extent && { extent: options.extent })
140
+ };
141
+ return new View(viewOptions);
142
+ }
143
+ catch (error) {
144
+ throw new MyOpenLayersError(`视图创建失败: ${error instanceof Error ? error.message : '未知错误'}`, ErrorType.MAP_ERROR, { options });
145
+ }
146
+ }
147
+ /**
148
+ * 获取视图(向后兼容)
149
+ * @deprecated 请使用 createView 方法
150
+ */
151
+ static getView(options = MyOl.DefaultOptions) {
152
+ console.warn('getView 方法已废弃,请使用 createView 方法');
153
+ return MyOl.createView(options);
154
+ }
155
+ // ==========================================
156
+ // 功能模块获取方法(懒加载模式)
157
+ // ==========================================
158
+ /**
159
+ * 获取面要素操作模块
160
+ * @returns Polygon 面要素操作实例
74
161
  */
75
162
  getPolygon() {
76
- if (!this.polygon)
77
- this.polygon = new Polygon(this.map);
78
- return this.polygon;
163
+ try {
164
+ if (!this._polygon) {
165
+ this._polygon = new Polygon(this.map);
166
+ console.debug('面要素模块已加载');
167
+ }
168
+ return this._polygon;
169
+ }
170
+ catch (error) {
171
+ this.errorHandler.handleError(new MyOpenLayersError('面要素模块初始化失败', ErrorType.COMPONENT_ERROR, { error }));
172
+ throw error;
173
+ }
79
174
  }
175
+ /**
176
+ * 获取底图图层管理模块
177
+ * @returns MapBaseLayers 底图管理实例
178
+ */
80
179
  getMapBaseLayers() {
81
- if (Array.isArray(this.options.layers)) {
82
- console.warn('已设置默认底图,MapBaseLayers中的switchBaseLayer方法将失效');
83
- }
84
- const options = {
85
- layers: this.options.layers,
86
- annotation: this.options.annotation,
87
- zIndex: 1,
88
- mapClip: !!this.options.mapClipData,
89
- mapClipData: this.options.mapClipData,
90
- token: this.options.token || ''
91
- };
92
- if (!this.baseLayers)
93
- this.baseLayers = new MapBaseLayers(this.map, options);
94
- return this.baseLayers;
95
- }
96
- // ╔══════════╗
97
- // ║ 地图 点 ║
98
- // ╚══════════╝
99
- /**
100
- * 获取 地图 点 操作
101
- * @returns Point
180
+ try {
181
+ if (!this._baseLayers) {
182
+ // 检查是否设置了自定义底图
183
+ if (Array.isArray(this.options.layers)) {
184
+ console.warn('已设置默认底图,MapBaseLayers 中的 switchBaseLayer 方法将失效');
185
+ }
186
+ const layerOptions = {
187
+ layers: this.options.layers,
188
+ annotation: this.options.annotation,
189
+ zIndex: 1,
190
+ mapClip: !!this.options.mapClipData,
191
+ mapClipData: this.options.mapClipData,
192
+ token: this.options.token || ''
193
+ };
194
+ this._baseLayers = new MapBaseLayers(this.map, layerOptions);
195
+ console.debug('基础图层模块已加载');
196
+ }
197
+ return this._baseLayers;
198
+ }
199
+ catch (error) {
200
+ this.errorHandler.handleError(new MyOpenLayersError('基础图层模块初始化失败', ErrorType.COMPONENT_ERROR, { error }));
201
+ throw error;
202
+ }
203
+ }
204
+ /**
205
+ * 获取点要素操作模块
206
+ * @returns Point 点要素操作实例
102
207
  */
103
208
  getPoint() {
104
- if (!this.point)
105
- this.point = new Point(this.map);
106
- return this.point;
209
+ try {
210
+ if (!this._point) {
211
+ this._point = new Point(this.map);
212
+ console.debug('点要素模块已加载');
213
+ }
214
+ return this._point;
215
+ }
216
+ catch (error) {
217
+ this.errorHandler.handleError(new MyOpenLayersError('点要素模块初始化失败', ErrorType.COMPONENT_ERROR, { error }));
218
+ throw error;
219
+ }
107
220
  }
108
- // ╔══════════╗
109
- // ║ 地图 线 ║
110
- // ╚══════════╝
111
221
  /**
112
- * 获取 地图 线 操作
113
- * @returns Line
222
+ * 获取线要素操作模块
223
+ * @returns Line 线要素操作实例
114
224
  */
115
225
  getLine() {
116
- if (!this.line)
117
- this.line = new Line(this.map);
118
- return this.line;
226
+ try {
227
+ if (!this._line) {
228
+ this._line = new Line(this.map);
229
+ console.debug('线要素模块已加载');
230
+ }
231
+ return this._line;
232
+ }
233
+ catch (error) {
234
+ this.errorHandler.handleError(new MyOpenLayersError('线要素模块初始化失败', ErrorType.COMPONENT_ERROR, { error }));
235
+ throw error;
236
+ }
119
237
  }
120
- // ╔════════════╗
121
- // ║ 地图 工具 ║
122
- // ╚════════════╝
123
238
  /**
124
- * 获取 地图 工具 操作
125
- * @returns MapTools
239
+ * 获取地图工具模块
240
+ * @returns MapTools 地图工具实例
126
241
  */
127
242
  getTools() {
128
- if (!this.mapTools)
129
- this.mapTools = new MapTools(this.map);
130
- return this.mapTools;
243
+ try {
244
+ if (!this._mapTools) {
245
+ this._mapTools = new MapTools(this.map);
246
+ console.debug('工具模块已加载');
247
+ }
248
+ return this._mapTools;
249
+ }
250
+ catch (error) {
251
+ this.errorHandler.handleError(new MyOpenLayersError('工具模块初始化失败', ErrorType.COMPONENT_ERROR, { error }));
252
+ throw error;
253
+ }
131
254
  }
255
+ // ==========================================
256
+ // 地图操作方法
257
+ // ==========================================
258
+ /**
259
+ * 重置地图位置到初始中心点
260
+ * @param duration 动画持续时间(毫秒)
261
+ */
132
262
  resetPosition(duration = 3000) {
133
- if (!this.options.center)
134
- return console.error('未设置中心点');
135
- this.locationAction(this.options.center[0], this.options.center[1], this.options.zoom, duration);
263
+ try {
264
+ if (!this.options.center) {
265
+ throw new Error('未设置中心点,无法重置位置');
266
+ }
267
+ const [longitude, latitude] = this.options.center;
268
+ this.locationAction(longitude, latitude, this.options.zoom, duration);
269
+ }
270
+ catch (error) {
271
+ this.errorHandler.handleError(new MyOpenLayersError(`重置地图位置失败: ${error instanceof Error ? error.message : '未知错误'}`, ErrorType.MAP_ERROR, { center: this.options.center, duration }));
272
+ }
136
273
  }
137
274
  /**
138
- * 地图定位
139
- * @param lgtd 经度
140
- * @param lttd 纬度
275
+ * 地图定位到指定坐标
276
+ * @param longitude 经度
277
+ * @param latitude 纬度
141
278
  * @param zoom 缩放级别
142
- * @param duration 动画时间
279
+ * @param duration 动画持续时间(毫秒)
143
280
  */
144
- locationAction(lgtd, lttd, zoom = 20, duration = 3000) {
145
- this.getPoint().locationAction(lgtd, lttd, zoom, duration);
281
+ locationAction(longitude, latitude, zoom = 20, duration = 3000) {
282
+ try {
283
+ // 参数验证
284
+ if (typeof longitude !== 'number' || typeof latitude !== 'number') {
285
+ throw new Error('经纬度必须是数字类型');
286
+ }
287
+ if (longitude < -180 || longitude > 180) {
288
+ throw new Error('经度值必须在 -180 到 180 之间');
289
+ }
290
+ if (latitude < -90 || latitude > 90) {
291
+ throw new Error('纬度值必须在 -90 到 90 之间');
292
+ }
293
+ this.getPoint().locationAction(longitude, latitude, zoom, duration);
294
+ // 记录定位操作
295
+ console.debug('地图定位完成', {
296
+ longitude,
297
+ latitude,
298
+ zoom,
299
+ duration
300
+ });
301
+ }
302
+ catch (error) {
303
+ this.errorHandler.handleError(new MyOpenLayersError(`地图定位失败: ${error instanceof Error ? error.message : '未知错误'}`, ErrorType.MAP_ERROR, { longitude, latitude, zoom, duration }));
304
+ throw error;
305
+ }
146
306
  }
147
307
  /**
148
- * 地图监听事件
308
+ * 监听地图事件
149
309
  * @param eventType 事件类型
150
- * @param clickType 点击类型
151
310
  * @param callback 回调函数
311
+ * @param clickType 点击类型(可选)
152
312
  */
153
313
  mapOnEvent(eventType, callback, clickType) {
154
- MapTools.mapOnEvent(this.map, eventType, callback, clickType);
314
+ try {
315
+ if (typeof callback !== 'function') {
316
+ throw new Error('回调函数必须是函数类型');
317
+ }
318
+ MapTools.mapOnEvent(this.map, eventType, callback, clickType);
319
+ // 记录事件监听
320
+ console.debug('地图事件监听已添加', {
321
+ eventType,
322
+ clickType
323
+ });
324
+ }
325
+ catch (error) {
326
+ this.errorHandler.handleError(new MyOpenLayersError(`添加地图事件监听失败: ${error instanceof Error ? error.message : '未知错误'}`, ErrorType.MAP_ERROR, { eventType, clickType }));
327
+ throw error;
328
+ }
329
+ }
330
+ // ==========================================
331
+ // 管理器访问方法
332
+ // ==========================================
333
+ /**
334
+ * 获取错误处理器实例
335
+ * @returns ErrorHandler 错误处理器
336
+ */
337
+ getErrorHandler() {
338
+ return this.errorHandler;
339
+ }
340
+ /**
341
+ * 获取事件管理器实例
342
+ * @returns EventManager 事件管理器
343
+ */
344
+ getEventManager() {
345
+ return this.eventManager;
346
+ }
347
+ /**
348
+ * 获取配置管理器实例
349
+ * @returns ConfigManager 配置管理器
350
+ */
351
+ getConfigManager() {
352
+ return this.configManager;
353
+ }
354
+ /**
355
+ * 获取当前地图配置
356
+ * @returns MapInitType 地图配置
357
+ */
358
+ getMapOptions() {
359
+ return Object.freeze({ ...this.options });
360
+ }
361
+ /**
362
+ * 销毁地图实例和相关资源
363
+ */
364
+ destroy() {
365
+ try {
366
+ // 清理事件监听
367
+ this.eventManager.clear();
368
+ // 销毁功能模块
369
+ this._point = undefined;
370
+ this._line = undefined;
371
+ this._polygon = undefined;
372
+ this._mapTools = undefined;
373
+ this._baseLayers = undefined;
374
+ // 销毁地图
375
+ this.map.setTarget(undefined);
376
+ console.debug('地图实例已销毁', { map: this.map });
377
+ }
378
+ catch (error) {
379
+ this.errorHandler.handleError(new MyOpenLayersError(`销毁地图失败: ${error instanceof Error ? error.message : '未知错误'}`, ErrorType.MAP_ERROR));
380
+ }
155
381
  }
156
382
  }
383
+ // 默认配置
157
384
  MyOl.DefaultOptions = {
158
385
  layers: undefined,
159
386
  zoom: 10,
@@ -162,4 +389,9 @@ MyOl.DefaultOptions = {
162
389
  maxZoom: 20,
163
390
  extent: undefined
164
391
  };
392
+ // 坐标系配置
393
+ MyOl.PROJECTIONS = {
394
+ CGCS2000: "EPSG:4490",
395
+ CGCS2000_3_DEGREE: "EPSG:4549"
396
+ };
165
397
  export default MyOl;